* Reintroduce support for ZLIB_CONST in compat mode.
stream.next_out = dest;
stream.avail_out = 0;
- stream.next_in = (const unsigned char *)source;
+ stream.next_in = (z_const unsigned char *)source;
stream.avail_in = 0;
do {
avail = strm->avail_in;
next = strm->next_in;
strm->avail_in = dictLength;
- strm->next_in = (const unsigned char *)dictionary;
+ strm->next_in = (z_const unsigned char *)dictionary;
fill_window(s);
while (s->lookahead >= MIN_MATCH) {
str = s->strstart;
s->lookahead = 0;
s->prev_length = MIN_MATCH-1;
s->match_available = 0;
- strm->next_in = next;
+ strm->next_in = (z_const unsigned char *)next;
strm->avail_in = avail;
s->wrap = wrap;
return Z_OK;
return 0;
/* directly compress user buffer to file */
- state->strm.next_in = (const unsigned char *)buf;
+ state->strm.next_in = (z_const unsigned char *) buf;
do {
unsigned n = (unsigned)-1;
if (n > len)
*/
int32_t ZEXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc, out_func out, void *out_desc) {
struct inflate_state *state;
- const unsigned char *next; /* next input */
- unsigned char *put; /* next output */
- unsigned have, left; /* available input and output */
- uint32_t hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char *from; /* where to copy match bytes from */
- code here; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int32_t ret; /* return code */
+ z_const unsigned char *next; /* next input */
+ unsigned char *put; /* next output */
+ unsigned have, left; /* available input and output */
+ uint32_t hold; /* bit buffer */
+ unsigned bits; /* bits in bit buffer */
+ unsigned copy; /* number of stored or match bytes to copy */
+ unsigned char *from; /* where to copy match bytes from */
+ code here; /* current decoding table entry */
+ code last; /* parent table entry */
+ unsigned len; /* length to copy for repeats, bits to drop */
+ int32_t ret; /* return code */
static const uint16_t order[19] = /* permutation of code lengths */
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
void ZLIB_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start) {
/* start: inflate()'s starting value for strm->avail_out */
struct inflate_state *state;
- const unsigned char *in; /* local strm->next_in */
+ z_const unsigned char *in; /* local strm->next_in */
const unsigned char *last; /* have enough input while in < last */
unsigned char *out; /* local strm->next_out */
unsigned char *beg; /* inflate()'s initial strm->next_out */
do { \
strm->next_out = put; \
strm->avail_out = left; \
- strm->next_in = next; \
+ strm->next_in = (z_const unsigned char *)next; \
strm->avail_in = have; \
state->hold = hold; \
state->bits = bits; \
err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.next_out = compr;
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
d_stream.zfree = zfree;
d_stream.opaque = (void *)0;
- d_stream.next_in = (const unsigned char *)compr;
+ d_stream.next_in = compr;
d_stream.avail_in = 0;
d_stream.next_out = uncompr;
d_stream.total_in = 0;
/* At this point, uncompr is still mostly zeroes, so it should compress
* very well:
*/
- c_stream.next_in = (const unsigned char *)uncompr;
+ c_stream.next_in = uncompr;
c_stream.avail_in = (unsigned int)uncomprLen;
err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
} else {
PREFIX(deflateParams)(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY);
}
- c_stream.next_in = (const unsigned char *)compr;
+ c_stream.next_in = compr;
diff = (unsigned int)(c_stream.next_out - compr);
c_stream.avail_in = diff;
err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
} else {
PREFIX(deflateParams)(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED);
}
- c_stream.next_in = (const unsigned char *)uncompr;
+ c_stream.next_in = uncompr;
c_stream.avail_in = (unsigned int)uncomprLen;
err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH);
CHECK_ERR(err, "deflate");
d_stream.zfree = zfree;
d_stream.opaque = (void *)0;
- d_stream.next_in = (const unsigned char *)compr;
+ d_stream.next_in = compr;
d_stream.avail_in = (unsigned int)comprLen;
d_stream.total_in = 0;
d_stream.total_out = 0;
err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.next_out = compr;
c_stream.avail_in = 3;
c_stream.avail_out = (unsigned int)*comprLen;
d_stream.zfree = zfree;
d_stream.opaque = (void *)0;
- d_stream.next_in = (const unsigned char *)compr;
+ d_stream.next_in = compr;
d_stream.avail_in = 2; /* just read the zlib header */
err = PREFIX(inflateInit)(&d_stream);
c_stream.next_out = compr;
c_stream.avail_out = (unsigned int)comprLen;
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.avail_in = (unsigned int)strlen(hello)+1;
err = PREFIX(deflate)(&c_stream, Z_FINISH);
d_stream.zfree = zfree;
d_stream.opaque = (void *)0;
d_stream.adler = 0;
- d_stream.next_in = (const unsigned char *)compr;
+ d_stream.next_in = compr;
d_stream.avail_in = (unsigned int)comprLen;
err = PREFIX(inflateInit)(&d_stream);
c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0;
c_stream.avail_in = len;
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.avail_out = 0;
c_stream.next_out = outBuf;
err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.next_out = compr;
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
c_stream.next_out = compr;
c_stream.avail_out = (uInt)comprLen;
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.avail_in = (unsigned int)strlen(hello)+1;
err = PREFIX(deflate)(&c_stream, Z_FINISH);
err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION);
CHECK_ERR(err, "deflateInit");
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.next_out = compr;
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
err = PREFIX(deflatePrime)(&c_stream, 8, 255);
CHECK_ERR(err, "deflatePrime");
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.avail_in = (uint32_t)len;
c_stream.next_out = compr;
c_stream.avail_out = (uint32_t)comprLen;
d_stream.zfree = zfree;
d_stream.opaque = (void *)0;
- d_stream.next_in = (const uint8_t *)compr;
+ d_stream.next_in = compr;
d_stream.avail_in = (uint32_t)c_stream.total_out;
d_stream.next_out = uncompr;
d_stream.avail_out = (uint32_t)uncomprLen;
printf("deflateTune(): OK\n");
}
- c_stream.next_in = (const unsigned char *)hello;
+ c_stream.next_in = (z_const unsigned char *)hello;
c_stream.next_out = compr;
while (c_stream.total_in != len && c_stream.total_out < comprLen) {
}
/* input and output functions for inflateBack() */
-static unsigned pull(void *desc, const unsigned char **buf) {
+static unsigned pull(void *desc, z_const unsigned char **buf) {
static unsigned int next = 0;
static unsigned char dat[] = {0x63, 0, 2, 0};
struct inflate_state *state;
if (read <= 0)
break;
- c_stream.next_in = (const uint8_t *)read_buf;
+ c_stream.next_in = (z_const uint8_t *)read_buf;
c_stream.next_out = write_buf;
c_stream.avail_in = read;
if (read <= 0)
break;
- d_stream.next_in = (const uint8_t *)read_buf;
+ d_stream.next_in = (z_const uint8_t *)read_buf;
d_stream.next_out = write_buf;
d_stream.avail_in = read;
dest = buf;
}
- stream.next_in = (const unsigned char *)source;
+ stream.next_in = (z_const unsigned char *)source;
stream.avail_in = 0;
stream.zalloc = NULL;
stream.zfree = NULL;
# define __has_declspec_attribute(x) 0
#endif
+/* Always define z_const as const */
+#define z_const const
+
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# define MAX_MEM_LEVEL 9
# define __has_declspec_attribute(x) 0
#endif
+#if defined(ZLIB_CONST) && !defined(z_const)
+# define z_const const
+#else
+# define z_const
+#endif
+
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# define MAX_MEM_LEVEL 9
struct internal_state;
typedef struct z_stream_s {
- const unsigned char *next_in; /* next input byte */
+ z_const unsigned char *next_in; /* next input byte */
uint32_t avail_in; /* number of bytes available at next_in */
unsigned long total_in; /* total number of input bytes read so far */
uint32_t avail_out; /* remaining free space at next_out */
unsigned long total_out; /* total number of bytes output so far */
- const char *msg; /* last error message, NULL if no error */
+ z_const char *msg; /* last error message, NULL if no error */
struct internal_state *state; /* not visible by applications */
alloc_func zalloc; /* used to allocate the internal state */
the version of the header file.
*/
-typedef uint32_t (*in_func) (void *, const unsigned char * *);
+typedef uint32_t (*in_func) (void *, z_const unsigned char * *);
typedef int (*out_func) (void *, unsigned char *, uint32_t);
ZEXTERN int ZEXPORT inflateBack(z_stream *strm, in_func in, void *in_desc, out_func out, void *out_desc);
# include "gzguts.h"
#endif
-const char * const PREFIX(z_errmsg)[10] = {
- (const char *)"need dictionary", /* Z_NEED_DICT 2 */
- (const char *)"stream end", /* Z_STREAM_END 1 */
- (const char *)"", /* Z_OK 0 */
- (const char *)"file error", /* Z_ERRNO (-1) */
- (const char *)"stream error", /* Z_STREAM_ERROR (-2) */
- (const char *)"data error", /* Z_DATA_ERROR (-3) */
- (const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
- (const char *)"buffer error", /* Z_BUF_ERROR (-5) */
- (const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
- (const char *)""
+z_const char * const PREFIX(z_errmsg)[10] = {
+ (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */
+ (z_const char *)"stream end", /* Z_STREAM_END 1 */
+ (z_const char *)"", /* Z_OK 0 */
+ (z_const char *)"file error", /* Z_ERRNO (-1) */
+ (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */
+ (z_const char *)"data error", /* Z_DATA_ERROR (-3) */
+ (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */
+ (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */
+ (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */
+ (z_const char *)""
};
const char zlibng_string[] =
typedef uint16_t ush; /* Included for compatibility with external code only */
typedef unsigned long ulg;
-extern const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */
+extern z_const char * const PREFIX(z_errmsg)[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) PREFIX(z_errmsg)[Z_NEED_DICT-(err)]