memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
*/
-int Z_EXPORT PREFIX(compress2)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source,
- z_uintmax_t sourceLen, int level) {
+z_int32_t Z_EXPORT PREFIX(compress2)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source,
+ z_uintmax_t sourceLen, z_int32_t level) {
PREFIX3(stream) stream;
int err;
const unsigned int max = (unsigned int)-1;
/* ===========================================================================
*/
-int Z_EXPORT PREFIX(compress)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t sourceLen) {
+z_int32_t Z_EXPORT PREFIX(compress)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t sourceLen) {
return PREFIX(compress2)(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
}
#endif
-int Z_EXPORT PREFIX(gzclose)(gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzclose)(gzFile file) {
#ifndef NO_GZCOMPRESS
gz_state *state;
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) {
+z_int32_t Z_EXPORT PREFIX(gzbuffer)(gzFile file, z_uint32_t size) {
gz_state *state;
/* get internal structure and check integrity */
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzrewind)(gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzrewind)(gzFile file) {
gz_state *state;
/* get internal structure */
#endif
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzeof)(gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzeof)(gzFile file) {
gz_state *state;
/* get internal structure and check integrity */
}
/* -- see zlib.h -- */
-const char * Z_EXPORT PREFIX(gzerror)(gzFile file, int *errnum) {
+const char * Z_EXPORT PREFIX(gzerror)(gzFile file, z_int32_t *errnum) {
gz_state *state;
/* get internal structure and check integrity */
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzread)(gzFile file, void *buf, unsigned len) {
+z_int32_t Z_EXPORT PREFIX(gzread)(gzFile file, void *buf, z_uint32_t len) {
gz_state *state;
/* get internal structure */
/* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids a flaw in the interface) */
- if ((int)len < 0) {
+ if ((z_int32_t)len < 0) {
gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
return -1;
}
return -1;
/* return the number of bytes read (this is assured to fit in an int) */
- return (int)len;
+ return (z_int32_t)len;
}
/* -- see zlib.h -- */
/* -- see zlib.h -- */
#undef @ZLIB_SYMBOL_PREFIX@gzgetc
#undef @ZLIB_SYMBOL_PREFIX@zng_gzgetc
-int Z_EXPORT PREFIX(gzgetc)(gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzgetc)(gzFile file) {
unsigned char buf[1];
gz_state *state;
#endif
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzungetc)(int c, gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzungetc)(z_int32_t c, gzFile file) {
gz_state *state;
/* get internal structure */
}
/* -- see zlib.h -- */
-char * Z_EXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) {
+char * Z_EXPORT PREFIX(gzgets)(gzFile file, char *buf, z_int32_t len) {
unsigned left, n;
char *str;
unsigned char *eol;
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzdirect)(gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzdirect)(gzFile file) {
gz_state *state;
/* get internal structure */
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzclose_r)(gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzclose_r)(gzFile file) {
int ret, err;
gz_state *state;
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzwrite)(gzFile file, void const *buf, unsigned len) {
+z_int32_t Z_EXPORT PREFIX(gzwrite)(gzFile file, void const *buf, z_uint32_t len) {
gz_state *state;
/* get internal structure */
/* since an int is returned, make sure len fits in one, otherwise return
with an error (this avoids a flaw in the interface) */
- if ((int)len < 0) {
+ if ((z_int32_t)len < 0) {
gz_error(state, Z_DATA_ERROR, "requested length does not fit in int");
return 0;
}
/* write len bytes from buf (the return value will fit in an int) */
- return (int)gz_write(state, buf, len);
+ return (z_int32_t)gz_write(state, buf, len);
}
/* -- see zlib.h -- */
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzputc)(gzFile file, int c) {
+z_int32_t Z_EXPORT PREFIX(gzputc)(gzFile file, z_int32_t c) {
unsigned have;
unsigned char buf[1];
gz_state *state;
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzputs)(gzFile file, const char *s) {
+z_int32_t Z_EXPORT PREFIX(gzputs)(gzFile file, const char *s) {
size_t len, put;
gz_state *state;
}
/* -- see zlib.h -- */
-int Z_EXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) {
+z_int32_t Z_EXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) {
int len;
unsigned left;
char *next;
return len;
}
-int Z_EXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) {
+z_int32_t Z_EXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) {
va_list va;
int ret;
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzflush)(gzFile file, int flush) {
+z_int32_t Z_EXPORT PREFIX(gzflush)(gzFile file, z_int32_t flush) {
gz_state *state;
/* get internal structure */
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) {
+z_int32_t Z_EXPORT PREFIX(gzsetparams)(gzFile file, z_int32_t level, z_int32_t strategy) {
gz_state *state;
PREFIX3(stream) *strm;
}
/* -- see zlib.h -- */
-int Z_EXPORT PREFIX(gzclose_w)(gzFile file) {
+z_int32_t Z_EXPORT PREFIX(gzclose_w)(gzFile file) {
int ret = Z_OK;
gz_state *state;
#ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else
- int err;
+ z_int32_t err;
size_t read;
size_t len = strlen(hello)+1;
gzFile file;
PREFIX3(stream) c_stream; /* compression stream */
int err;
unsigned char *dictNew = NULL;
- unsigned int *dictLen;
+ z_uint32_t *dictLen;
c_stream.zalloc = zalloc;
c_stream.zfree = zfree;
error("deflate should report Z_STREAM_END\n");
dictNew = calloc(256, 1);
- dictLen = (unsigned int *)calloc(4, 1);
+ dictLen = (z_uint32_t *)calloc(4, 1);
err = PREFIX(deflateGetDictionary)(&c_stream, dictNew, dictLen);
CHECK_ERR(err, "deflateGetDictionary");
static void test_deflate_pending(unsigned char *compr, size_t comprLen) {
PREFIX3(stream) c_stream; /* compression stream */
int err;
- int *bits = calloc(256, 1);
- unsigned *ped = calloc(256, 1);
+ z_int32_t *bits = calloc(256, 1);
+ z_uint32_t *ped = calloc(256, 1);
size_t len = strlen(hello)+1;
}
/* input and output functions for inflateBack() */
-static unsigned pull(void *desc, z_const unsigned char **buf) {
+static z_uint32_t 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;
return next < sizeof(dat) ? (*buf = dat + next++, 1) : 0;
}
-static int push(void *desc, unsigned char *buf, unsigned len) {
+static z_int32_t push(void *desc, unsigned char *buf, z_uint32_t len) {
buf += len;
Z_UNUSED(buf);
return desc != NULL; /* force error if desc not null */
#include "zbuild.h"
+#include <inttypes.h>
#include <stdio.h>
#include <assert.h>
read_buf = (uint8_t *)malloc(read_buf_size);
if (read_buf == NULL) {
- fprintf(stderr, "failed to create read buffer (%d)\n", read_buf_size);
+ fprintf(stderr, "failed to create read buffer (%" PRId32 ")\n", read_buf_size);
return;
}
write_buf = (uint8_t *)malloc(write_buf_size);
if (write_buf == NULL) {
- fprintf(stderr, "failed to create write buffer (%d)\n", write_buf_size);
+ fprintf(stderr, "failed to create write buffer (%" PRId32 ")\n", write_buf_size);
free(read_buf);
return;
}
read_buf = (uint8_t *)malloc(read_buf_size);
if (read_buf == NULL) {
- fprintf(stderr, "failed to create read buffer (%d)\n", read_buf_size);
+ fprintf(stderr, "failed to create read buffer (%" PRId32 ")\n", read_buf_size);
return;
}
write_buf = (uint8_t *)malloc(write_buf_size);
if (write_buf == NULL) {
- fprintf(stderr, "failed to create write buffer (%d)\n", write_buf_size);
+ fprintf(stderr, "failed to create write buffer (%" PRId32 ")\n", write_buf_size);
free(read_buf);
return;
}
*/
static void gz_fatal(gzFile file) {
- int err;
+ z_int32_t err;
fprintf(stderr, "%s: %s\n", prog, PREFIX(gzerror)(file, &err));
PREFIX(gzclose)(file);
exit(1);
# include "zlib-ng.h"
#endif
+#include <inttypes.h>
#include <stdio.h>
#if defined(_WIN32) || defined(__CYGWIN__)
goto free_buf;
}
if (strm->avail_in != 0) {
- fprintf(stderr, "deflate() did not consume %d bytes of input\n", strm->avail_in);
+ fprintf(stderr, "deflate() did not consume %" PRIu32 " bytes of input\n", strm->avail_in);
goto free_buf;
}
if (write_all(buf + size, compsize - strm->avail_out) != 0) {
Z_DATA_ERROR if the input data was corrupted, including if the input data is
an incomplete zlib stream.
*/
-int Z_EXPORT PREFIX(uncompress2)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t *sourceLen) {
+z_int32_t Z_EXPORT PREFIX(uncompress2)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t *sourceLen) {
PREFIX3(stream) stream;
int err;
const unsigned int max = (unsigned int)-1;
err;
}
-int Z_EXPORT PREFIX(uncompress)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t sourceLen) {
+z_int32_t Z_EXPORT PREFIX(uncompress)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t sourceLen) {
return PREFIX(uncompress2)(dest, destLen, source, &sourceLen);
}
# define z_uintmax_t size_t
#endif
+/* In zlib-compat headers some function return values and parameter types use int or unsigned, but zlib-ng headers use
+ int32_t and uint32_t, which will cause type mismatch when compiling zlib-ng if int32_t is long and uint32_t is
+ unsigned long */
+#if defined(ZLIB_COMPAT)
+# define z_int32_t int
+# define z_uint32_t unsigned int
+#else
+# define z_int32_t int32_t
+# define z_uint32_t uint32_t
+#endif
+
/* Minimum of a and b. */
#define MIN(a, b) ((a) > (b) ? (b) : (a))
/* Maximum of a and b. */
/* exported to allow conversion of error code to string for compress() and
* uncompress()
*/
-const char * Z_EXPORT PREFIX(zError)(int err) {
+const char * Z_EXPORT PREFIX(zError)(z_int32_t err) {
return ERR_MSG(err);
}