提交 f442c1e8 编写于 作者: M Mark Adler

Add a ./config --solo option to make zlib subset with no libary use

A common request has been the ability to compile zlib to require no
other libraries.  This --solo option provides that ability.  The price
is that the gz*, compress*, and uncompress functions are eliminated,
and that the user must provide memory allocation and free routines to
deflate and inflate when initializing.
上级 518ad017
...@@ -54,11 +54,13 @@ man3dir = ${mandir}/man3 ...@@ -54,11 +54,13 @@ man3dir = ${mandir}/man3
pkgconfigdir = ${libdir}/pkgconfig pkgconfigdir = ${libdir}/pkgconfig
tempfile := $(shell mktemp -u __XXXXXX) tempfile := $(shell mktemp -u __XXXXXX)
OBJC = adler32.o compress.o crc32.o deflate.o gzclose.o gzlib.o gzread.o \ OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o
gzwrite.o infback.o inffast.o inflate.o inftrees.o trees.o uncompr.o zutil.o OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o
OBJC = $(OBJZ) $(OBJG)
PIC_OBJC = adler32.lo compress.lo crc32.lo deflate.lo gzclose.lo gzlib.lo gzread.lo \ PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo
gzwrite.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo uncompr.lo zutil.lo PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
# to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo
OBJA = OBJA =
......
...@@ -54,11 +54,14 @@ includedir=${includedir-'${prefix}/include'} ...@@ -54,11 +54,14 @@ includedir=${includedir-'${prefix}/include'}
mandir=${mandir-'${prefix}/share/man'} mandir=${mandir-'${prefix}/share/man'}
shared_ext='.so' shared_ext='.so'
shared=1 shared=1
solo=0
zprefix=0 zprefix=0
build64=0 build64=0
gcc=0 gcc=0
old_cc="$CC" old_cc="$CC"
old_cflags="$CFLAGS" old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
PIC_OBJC='$(PIC_OBJZ) $(PIC_OBJG)'
while test $# -ge 1 while test $# -ge 1
do do
...@@ -81,6 +84,7 @@ case "$1" in ...@@ -81,6 +84,7 @@ case "$1" in
-i* | --includedir) includedir="$2"; shift; shift ;; -i* | --includedir) includedir="$2"; shift; shift ;;
-s* | --shared | --enable-shared) shared=1; shift ;; -s* | --shared | --enable-shared) shared=1; shift ;;
-t | --static) shared=0; shift ;; -t | --static) shared=0; shift ;;
--solo) solo=1; shift ;;
-z* | --zprefix) zprefix=1; shift ;; -z* | --zprefix) zprefix=1; shift ;;
-6* | --64) build64=1; shift ;; -6* | --64) build64=1; shift ;;
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;; -a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
...@@ -331,6 +335,16 @@ if test $zprefix -eq 1; then ...@@ -331,6 +335,16 @@ if test $zprefix -eq 1; then
echo "Using z_ prefix on all symbols." echo "Using z_ prefix on all symbols."
fi fi
if test $solo -eq 1; then
sed '/#define ZCONF_H/a\
#define Z_SOLO
' < zconf.h > zconf.temp.h
mv zconf.temp.h zconf.h
OBJC='$(OBJZ)'
PIC_OBJC='$(PIC_OBJZ)'
fi
cat > $test.c <<EOF cat > $test.c <<EOF
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
...@@ -589,6 +603,8 @@ sed < Makefile.in " ...@@ -589,6 +603,8 @@ sed < Makefile.in "
/^sharedlibdir *=/s#=.*#=$sharedlibdir# /^sharedlibdir *=/s#=.*#=$sharedlibdir#
/^includedir *=/s#=.*#=$includedir# /^includedir *=/s#=.*#=$includedir#
/^mandir *=/s#=.*#=$mandir# /^mandir *=/s#=.*#=$mandir#
/^OBJC *=/s#=.*#= $OBJC#
/^PIC_OBJC *=/s#=.*#= $PIC_OBJC#
/^all: */s#:.*#: $ALL# /^all: */s#:.*#: $ALL#
/^test: */s#:.*#: $TEST# /^test: */s#:.*#: $TEST#
" > Makefile " > Makefile
......
...@@ -235,10 +235,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, ...@@ -235,10 +235,19 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
strm->msg = Z_NULL; strm->msg = Z_NULL;
if (strm->zalloc == (alloc_func)0) { if (strm->zalloc == (alloc_func)0) {
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zalloc = zcalloc; strm->zalloc = zcalloc;
strm->opaque = (voidpf)0; strm->opaque = (voidpf)0;
#endif
} }
if (strm->zfree == (free_func)0) strm->zfree = zcfree; if (strm->zfree == (free_func)0)
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zfree = zcfree;
#endif
#ifdef FASTEST #ifdef FASTEST
if (level != 0) level = 1; if (level != 0) level = 1;
...@@ -957,12 +966,12 @@ int ZEXPORT deflateCopy (dest, source) ...@@ -957,12 +966,12 @@ int ZEXPORT deflateCopy (dest, source)
ss = source->state; ss = source->state;
zmemcpy(dest, source, sizeof(z_stream)); zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
if (ds == Z_NULL) return Z_MEM_ERROR; if (ds == Z_NULL) return Z_MEM_ERROR;
dest->state = (struct internal_state FAR *) ds; dest->state = (struct internal_state FAR *) ds;
zmemcpy(ds, ss, sizeof(deflate_state)); zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state));
ds->strm = dest; ds->strm = dest;
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
...@@ -978,8 +987,8 @@ int ZEXPORT deflateCopy (dest, source) ...@@ -978,8 +987,8 @@ int ZEXPORT deflateCopy (dest, source)
} }
/* following zmemcpy do not work for 16-bit MSDOS */ /* following zmemcpy do not work for 16-bit MSDOS */
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
zmemcpy(ds->prev, ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
zmemcpy(ds->head, ss->head, ds->hash_size * sizeof(Pos)); zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
......
...@@ -34,10 +34,6 @@ const char hello[] = "hello, hello!"; ...@@ -34,10 +34,6 @@ const char hello[] = "hello, hello!";
const char dictionary[] = "hello"; const char dictionary[] = "hello";
uLong dictId; /* Adler32 value of the dictionary */ uLong dictId; /* Adler32 value of the dictionary */
void test_compress OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname,
Byte *uncompr, uLong uncomprLen));
void test_deflate OF((Byte *compr, uLong comprLen)); void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen, void test_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte *uncompr, uLong uncomprLen));
...@@ -53,6 +49,39 @@ void test_dict_inflate OF((Byte *compr, uLong comprLen, ...@@ -53,6 +49,39 @@ void test_dict_inflate OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen)); Byte *uncompr, uLong uncomprLen));
int main OF((int argc, char *argv[])); int main OF((int argc, char *argv[]));
#ifdef Z_SOLO
void *myalloc OF((void *, unsigned, unsigned));
void myfree OF((void *, void *));
void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
q = Z_NULL;
return calloc(n, m);
}
void myfree(void *q, void *p)
{
q = Z_NULL;
free(p);
}
static alloc_func zalloc = myalloc;
static free_func zfree = myfree;
#else /* !Z_SOLO */
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;
void test_compress OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname,
Byte *uncompr, uLong uncomprLen));
/* =========================================================================== /* ===========================================================================
* Test compress() and uncompress() * Test compress() and uncompress()
*/ */
...@@ -163,6 +192,8 @@ void test_gzio(fname, uncompr, uncomprLen) ...@@ -163,6 +192,8 @@ void test_gzio(fname, uncompr, uncomprLen)
#endif #endif
} }
#endif /* Z_SOLO */
/* =========================================================================== /* ===========================================================================
* Test deflate() with small buffers * Test deflate() with small buffers
*/ */
...@@ -174,8 +205,8 @@ void test_deflate(compr, comprLen) ...@@ -174,8 +205,8 @@ void test_deflate(compr, comprLen)
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello)+1;
c_stream.zalloc = (alloc_func)0; c_stream.zalloc = zalloc;
c_stream.zfree = (free_func)0; c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0; c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
...@@ -213,8 +244,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen) ...@@ -213,8 +244,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
strcpy((char*)uncompr, "garbage"); strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0; d_stream.zalloc = zalloc;
d_stream.zfree = (free_func)0; d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0; d_stream.opaque = (voidpf)0;
d_stream.next_in = compr; d_stream.next_in = compr;
...@@ -252,8 +283,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen) ...@@ -252,8 +283,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
c_stream.zalloc = (alloc_func)0; c_stream.zalloc = zalloc;
c_stream.zfree = (free_func)0; c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0; c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_SPEED); err = deflateInit(&c_stream, Z_BEST_SPEED);
...@@ -309,8 +340,8 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) ...@@ -309,8 +340,8 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
strcpy((char*)uncompr, "garbage"); strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0; d_stream.zalloc = zalloc;
d_stream.zfree = (free_func)0; d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0; d_stream.opaque = (voidpf)0;
d_stream.next_in = compr; d_stream.next_in = compr;
...@@ -349,8 +380,8 @@ void test_flush(compr, comprLen) ...@@ -349,8 +380,8 @@ void test_flush(compr, comprLen)
int err; int err;
uInt len = (uInt)strlen(hello)+1; uInt len = (uInt)strlen(hello)+1;
c_stream.zalloc = (alloc_func)0; c_stream.zalloc = zalloc;
c_stream.zfree = (free_func)0; c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0; c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION);
...@@ -388,8 +419,8 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) ...@@ -388,8 +419,8 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
strcpy((char*)uncompr, "garbage"); strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0; d_stream.zalloc = zalloc;
d_stream.zfree = (free_func)0; d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0; d_stream.opaque = (voidpf)0;
d_stream.next_in = compr; d_stream.next_in = compr;
...@@ -430,8 +461,8 @@ void test_dict_deflate(compr, comprLen) ...@@ -430,8 +461,8 @@ void test_dict_deflate(compr, comprLen)
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
c_stream.zalloc = (alloc_func)0; c_stream.zalloc = zalloc;
c_stream.zfree = (free_func)0; c_stream.zfree = zfree;
c_stream.opaque = (voidpf)0; c_stream.opaque = (voidpf)0;
err = deflateInit(&c_stream, Z_BEST_COMPRESSION); err = deflateInit(&c_stream, Z_BEST_COMPRESSION);
...@@ -469,8 +500,8 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) ...@@ -469,8 +500,8 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
strcpy((char*)uncompr, "garbage"); strcpy((char*)uncompr, "garbage");
d_stream.zalloc = (alloc_func)0; d_stream.zalloc = zalloc;
d_stream.zfree = (free_func)0; d_stream.zfree = zfree;
d_stream.opaque = (voidpf)0; d_stream.opaque = (voidpf)0;
d_stream.next_in = compr; d_stream.next_in = compr;
...@@ -540,10 +571,15 @@ int main(argc, argv) ...@@ -540,10 +571,15 @@ int main(argc, argv)
printf("out of memory\n"); printf("out of memory\n");
exit(1); exit(1);
} }
#ifdef Z_SOLO
argc = strlen(argv[0]);
#else
test_compress(compr, comprLen, uncompr, uncomprLen); test_compress(compr, comprLen, uncompr, uncomprLen);
test_gzio((argc > 1 ? argv[1] : TESTFILE), test_gzio((argc > 1 ? argv[1] : TESTFILE),
uncompr, uncomprLen); uncompr, uncomprLen);
#endif
test_deflate(compr, comprLen); test_deflate(compr, comprLen);
test_inflate(compr, comprLen, uncompr, uncomprLen); test_inflate(compr, comprLen, uncompr, uncomprLen);
......
...@@ -42,10 +42,19 @@ int stream_size; ...@@ -42,10 +42,19 @@ int stream_size;
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
strm->msg = Z_NULL; /* in case we return an error */ strm->msg = Z_NULL; /* in case we return an error */
if (strm->zalloc == (alloc_func)0) { if (strm->zalloc == (alloc_func)0) {
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zalloc = zcalloc; strm->zalloc = zcalloc;
strm->opaque = (voidpf)0; strm->opaque = (voidpf)0;
#endif
} }
if (strm->zfree == (free_func)0) strm->zfree = zcfree; if (strm->zfree == (free_func)0)
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zfree = zcfree;
#endif
state = (struct inflate_state FAR *)ZALLOC(strm, 1, state = (struct inflate_state FAR *)ZALLOC(strm, 1,
sizeof(struct inflate_state)); sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR; if (state == Z_NULL) return Z_MEM_ERROR;
......
...@@ -180,10 +180,19 @@ int stream_size; ...@@ -180,10 +180,19 @@ int stream_size;
if (strm == Z_NULL) return Z_STREAM_ERROR; if (strm == Z_NULL) return Z_STREAM_ERROR;
strm->msg = Z_NULL; /* in case we return an error */ strm->msg = Z_NULL; /* in case we return an error */
if (strm->zalloc == (alloc_func)0) { if (strm->zalloc == (alloc_func)0) {
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zalloc = zcalloc; strm->zalloc = zcalloc;
strm->opaque = (voidpf)0; strm->opaque = (voidpf)0;
#endif
} }
if (strm->zfree == (free_func)0) strm->zfree = zcfree; if (strm->zfree == (free_func)0)
#ifdef Z_SOLO
return Z_STREAM_ERROR;
#else
strm->zfree = zcfree;
#endif
state = (struct inflate_state FAR *) state = (struct inflate_state FAR *)
ZALLOC(strm, 1, sizeof(struct inflate_state)); ZALLOC(strm, 1, sizeof(struct inflate_state));
if (state == Z_NULL) return Z_MEM_ERROR; if (state == Z_NULL) return Z_MEM_ERROR;
...@@ -1433,8 +1442,8 @@ z_streamp source; ...@@ -1433,8 +1442,8 @@ z_streamp source;
} }
/* copy state */ /* copy state */
zmemcpy(dest, source, sizeof(z_stream)); zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
zmemcpy(copy, state, sizeof(struct inflate_state)); zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
if (state->lencode >= state->codes && if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) { state->lencode <= state->codes + ENOUGH - 1) {
copy->lencode = copy->codes + (state->lencode - state->codes); copy->lencode = copy->codes + (state->lencode - state->codes);
......
/* minigzip.c -- simulate gzip using the zlib compression library /* minigzip.c -- simulate gzip using the zlib compression library
* Copyright (C) 1995-2006, 2010 Jean-loup Gailly. * Copyright (C) 1995-2006, 2010, 2011 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
...@@ -138,6 +138,197 @@ static void pwinerror (s) ...@@ -138,6 +138,197 @@ static void pwinerror (s)
# define local # define local
#endif #endif
#ifdef Z_SOLO
/* for Z_SOLO, create simplified gz* functions using deflate and inflate */
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)
# include <unistd.h> /* for unlink() */
#endif
void *myalloc OF((void *, unsigned, unsigned));
void myfree OF((void *, void *));
void *myalloc(q, n, m)
void *q;
unsigned n, m;
{
q = Z_NULL;
return calloc(n, m);
}
void myfree(q, p)
void *q, *p;
{
q = Z_NULL;
free(p);
}
typedef struct gzFile_s {
FILE *file;
int write;
int err;
char *msg;
z_stream strm;
} *gzFile;
gzFile gzopen OF((const char *, const char *));
gzFile gzdopen OF((int, const char *));
gzFile gz_open OF((const char *, int, const char *));
gzFile gzopen(path, mode)
const char *path;
const char *mode;
{
return gz_open(path, -1, mode);
}
gzFile gzdopen(fd, mode)
int fd;
const char *mode;
{
return gz_open(NULL, fd, mode);
}
gzFile gz_open(path, fd, mode)
const char *path;
int fd;
const char *mode;
{
gzFile gz;
int ret;
gz = malloc(sizeof(gzFile));
if (gz == NULL)
return NULL;
gz->write = strchr(mode, 'w') != NULL;
gz->strm.zalloc = myalloc;
gz->strm.zfree = myfree;
gz->strm.opaque = Z_NULL;
if (gz->write)
ret = deflateInit2(&(gz->strm), -1, 8, 15 + 16, 8, 0);
else {
gz->strm.next_in = 0;
gz->strm.avail_in = Z_NULL;
ret = inflateInit2(&(gz->strm), 15 + 16);
}
if (ret != Z_OK) {
free(gz);
return NULL;
}
gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
fopen(path, gz->write ? "wb" : "rb");
if (gz->file == NULL) {
gz->write ? deflateEnd(&(gz->strm)) : inflateEnd(&(gz->strm));
free(gz);
return NULL;
}
gz->err = 0;
gz->msg = "";
return gz;
}
int gzwrite OF((gzFile, const void *, unsigned));
int gzwrite(gz, buf, len)
gzFile gz;
const void *buf;
unsigned len;
{
z_stream *strm;
unsigned char out[BUFLEN];
if (gz == NULL || !gz->write)
return 0;
strm = &(gz->strm);
strm->next_in = (void *)buf;
strm->avail_in = len;
do {
strm->next_out = out;
strm->avail_out = BUFLEN;
(void)deflate(strm, Z_NO_FLUSH);
fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
} while (strm->avail_out == 0);
return len;
}
int gzread OF((gzFile, void *, unsigned));
int gzread(gz, buf, len)
gzFile gz;
void *buf;
unsigned len;
{
int ret;
unsigned got;
unsigned char in[1];
z_stream *strm;
if (gz == NULL || gz->write)
return 0;
if (gz->err)
return 0;
strm = &(gz->strm);
strm->next_out = (void *)buf;
strm->avail_out = len;
do {
got = fread(in, 1, 1, gz->file);
if (got == 0)
break;
strm->next_in = in;
strm->avail_in = 1;
ret = inflate(strm, Z_NO_FLUSH);
if (ret == Z_DATA_ERROR) {
gz->err = Z_DATA_ERROR;
gz->msg = strm->msg;
return 0;
}
if (ret == Z_STREAM_END)
inflateReset(strm);
} while (strm->avail_out);
return len - strm->avail_out;
}
int gzclose OF((gzFile));
int gzclose(gz)
gzFile gz;
{
z_stream *strm;
unsigned char out[BUFLEN];
if (gz == NULL)
return Z_STREAM_ERROR;
strm = &(gz->strm);
if (gz->write) {
strm->next_in = Z_NULL;
strm->avail_in = 0;
do {
strm->next_out = out;
strm->avail_out = BUFLEN;
(void)deflate(strm, Z_FINISH);
fwrite(out, 1, BUFLEN - strm->avail_out, gz->file);
} while (strm->avail_out == 0);
deflateEnd(strm);
}
else
inflateEnd(strm);
fclose(gz->file);
free(gz);
return Z_OK;
}
const char *gzerror OF((gzFile, int *));
const char *gzerror(gz, err)
gzFile gz;
int *err;
{
*err = gz->err;
return gz->msg;
}
#endif
char *prog; char *prog;
void error OF((const char *msg)); void error OF((const char *msg));
......
...@@ -28,9 +28,11 @@ ...@@ -28,9 +28,11 @@
# define adler32 z_adler32 # define adler32 z_adler32
# define adler32_combine z_adler32_combine # define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64 # define adler32_combine64 z_adler32_combine64
# define compress z_compress # ifndef Z_SOLO
# define compress2 z_compress2 # define compress z_compress
# define compressBound z_compressBound # define compress2 z_compress2
# define compressBound z_compressBound
# endif
# define crc32 z_crc32 # define crc32 z_crc32
# define crc32_combine z_crc32_combine # define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64 # define crc32_combine64 z_crc32_combine64
...@@ -49,39 +51,41 @@ ...@@ -49,39 +51,41 @@
# define deflateTune z_deflateTune # define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright # define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table # define get_crc_table z_get_crc_table
# define gz_error z_gz_error # ifndef Z_SOLO
# define gz_intmax z_gz_intmax # define gz_error z_gz_error
# define gz_strwinerror z_gz_strwinerror # define gz_intmax z_gz_intmax
# define gzbuffer z_gzbuffer # define gz_strwinerror z_gz_strwinerror
# define gzclearerr z_gzclearerr # define gzbuffer z_gzbuffer
# define gzclose z_gzclose # define gzclearerr z_gzclearerr
# define gzclose_r z_gzclose_r # define gzclose z_gzclose
# define gzclose_w z_gzclose_w # define gzclose_r z_gzclose_r
# define gzdirect z_gzdirect # define gzclose_w z_gzclose_w
# define gzdopen z_gzdopen # define gzdirect z_gzdirect
# define gzeof z_gzeof # define gzdopen z_gzdopen
# define gzerror z_gzerror # define gzeof z_gzeof
# define gzflags z_gzflags # define gzerror z_gzerror
# define gzflush z_gzflush # define gzflags z_gzflags
# define gzgetc z_gzgetc # define gzflush z_gzflush
# define gzgetc_ z_gzgetc_ # define gzgetc z_gzgetc
# define gzgets z_gzgets # define gzgetc_ z_gzgetc_
# define gzoffset z_gzoffset # define gzgets z_gzgets
# define gzoffset64 z_gzoffset64 # define gzoffset z_gzoffset
# define gzopen z_gzopen # define gzoffset64 z_gzoffset64
# define gzopen64 z_gzopen64 # define gzopen z_gzopen
# define gzprintf z_gzprintf # define gzopen64 z_gzopen64
# define gzputc z_gzputc # define gzprintf z_gzprintf
# define gzputs z_gzputs # define gzputc z_gzputc
# define gzread z_gzread # define gzputs z_gzputs
# define gzrewind z_gzrewind # define gzread z_gzread
# define gzseek z_gzseek # define gzrewind z_gzrewind
# define gzseek64 z_gzseek64 # define gzseek z_gzseek
# define gzsetparams z_gzsetparams # define gzseek64 z_gzseek64
# define gztell z_gztell # define gzsetparams z_gzsetparams
# define gztell64 z_gztell64 # define gztell z_gztell
# define gzungetc z_gzungetc # define gztell64 z_gztell64
# define gzwrite z_gzwrite # define gzungetc z_gzungetc
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate # define inflate z_inflate
# define inflateBack z_inflateBack # define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd # define inflateBackEnd z_inflateBackEnd
...@@ -102,10 +106,14 @@ ...@@ -102,10 +106,14 @@
# define inflate_copyright z_inflate_copyright # define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast # define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table # define inflate_table z_inflate_table
# define uncompress z_uncompress # ifndef Z_SOLO
# define uncompress z_uncompress
# endif
# define zError z_zError # define zError z_zError
# define zcalloc z_zcalloc # ifndef Z_SOLO
# define zcfree z_zcfree # define zcalloc z_zcalloc
# define zcfree z_zcfree
# endif
# define zlibCompileFlags z_zlibCompileFlags # define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion # define zlibVersion z_zlibVersion
...@@ -115,9 +123,11 @@ ...@@ -115,9 +123,11 @@
# define alloc_func z_alloc_func # define alloc_func z_alloc_func
# define charf z_charf # define charf z_charf
# define free_func z_free_func # define free_func z_free_func
# define gzFile z_gzFile # ifndef Z_SOLO
# define gz_header z_gz_header # define gzFile z_gzFile
# define gz_headerp z_gz_headerp # define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# endif
# define in_func z_in_func # define in_func z_in_func
# define intf z_intf # define intf z_intf
# define out_func z_out_func # define out_func z_out_func
...@@ -130,7 +140,9 @@ ...@@ -130,7 +140,9 @@
# define voidpf z_voidpf # define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */ /* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s # ifndef Z_SOLO
# define gz_header_s z_gz_header_s
# endif
# define internal_state z_internal_state # define internal_state z_internal_state
#endif #endif
...@@ -377,7 +389,9 @@ typedef uLong FAR uLongf; ...@@ -377,7 +389,9 @@ typedef uLong FAR uLongf;
#endif #endif
#ifdef STDC #ifdef STDC
# include <sys/types.h> /* for off_t */ # ifndef Z_SOLO
# include <sys/types.h> /* for off_t */
# endif
#endif #endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
...@@ -394,7 +408,7 @@ typedef uLong FAR uLongf; ...@@ -394,7 +408,7 @@ typedef uLong FAR uLongf;
# define Z_LARGE # define Z_LARGE
#endif #endif
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) #if (defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)) && !defined(Z_SOLO)
# include <unistd.h> /* for SEEK_* and off_t */ # include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS # ifdef VMS
# include <unixio.h> /* for off_t */ # include <unixio.h> /* for off_t */
...@@ -404,7 +418,7 @@ typedef uLong FAR uLongf; ...@@ -404,7 +418,7 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#ifndef SEEK_SET #if !defined(SEEK_SET) && !defined(Z_SOLO)
# define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
......
...@@ -30,9 +30,11 @@ ...@@ -30,9 +30,11 @@
# define adler32 z_adler32 # define adler32 z_adler32
# define adler32_combine z_adler32_combine # define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64 # define adler32_combine64 z_adler32_combine64
# define compress z_compress # ifndef Z_SOLO
# define compress2 z_compress2 # define compress z_compress
# define compressBound z_compressBound # define compress2 z_compress2
# define compressBound z_compressBound
# endif
# define crc32 z_crc32 # define crc32 z_crc32
# define crc32_combine z_crc32_combine # define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64 # define crc32_combine64 z_crc32_combine64
...@@ -51,39 +53,41 @@ ...@@ -51,39 +53,41 @@
# define deflateTune z_deflateTune # define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright # define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table # define get_crc_table z_get_crc_table
# define gz_error z_gz_error # ifndef Z_SOLO
# define gz_intmax z_gz_intmax # define gz_error z_gz_error
# define gz_strwinerror z_gz_strwinerror # define gz_intmax z_gz_intmax
# define gzbuffer z_gzbuffer # define gz_strwinerror z_gz_strwinerror
# define gzclearerr z_gzclearerr # define gzbuffer z_gzbuffer
# define gzclose z_gzclose # define gzclearerr z_gzclearerr
# define gzclose_r z_gzclose_r # define gzclose z_gzclose
# define gzclose_w z_gzclose_w # define gzclose_r z_gzclose_r
# define gzdirect z_gzdirect # define gzclose_w z_gzclose_w
# define gzdopen z_gzdopen # define gzdirect z_gzdirect
# define gzeof z_gzeof # define gzdopen z_gzdopen
# define gzerror z_gzerror # define gzeof z_gzeof
# define gzflags z_gzflags # define gzerror z_gzerror
# define gzflush z_gzflush # define gzflags z_gzflags
# define gzgetc z_gzgetc # define gzflush z_gzflush
# define gzgetc_ z_gzgetc_ # define gzgetc z_gzgetc
# define gzgets z_gzgets # define gzgetc_ z_gzgetc_
# define gzoffset z_gzoffset # define gzgets z_gzgets
# define gzoffset64 z_gzoffset64 # define gzoffset z_gzoffset
# define gzopen z_gzopen # define gzoffset64 z_gzoffset64
# define gzopen64 z_gzopen64 # define gzopen z_gzopen
# define gzprintf z_gzprintf # define gzopen64 z_gzopen64
# define gzputc z_gzputc # define gzprintf z_gzprintf
# define gzputs z_gzputs # define gzputc z_gzputc
# define gzread z_gzread # define gzputs z_gzputs
# define gzrewind z_gzrewind # define gzread z_gzread
# define gzseek z_gzseek # define gzrewind z_gzrewind
# define gzseek64 z_gzseek64 # define gzseek z_gzseek
# define gzsetparams z_gzsetparams # define gzseek64 z_gzseek64
# define gztell z_gztell # define gzsetparams z_gzsetparams
# define gztell64 z_gztell64 # define gztell z_gztell
# define gzungetc z_gzungetc # define gztell64 z_gztell64
# define gzwrite z_gzwrite # define gzungetc z_gzungetc
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate # define inflate z_inflate
# define inflateBack z_inflateBack # define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd # define inflateBackEnd z_inflateBackEnd
...@@ -104,10 +108,14 @@ ...@@ -104,10 +108,14 @@
# define inflate_copyright z_inflate_copyright # define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast # define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table # define inflate_table z_inflate_table
# define uncompress z_uncompress # ifndef Z_SOLO
# define uncompress z_uncompress
# endif
# define zError z_zError # define zError z_zError
# define zcalloc z_zcalloc # ifndef Z_SOLO
# define zcfree z_zcfree # define zcalloc z_zcalloc
# define zcfree z_zcfree
# endif
# define zlibCompileFlags z_zlibCompileFlags # define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion # define zlibVersion z_zlibVersion
...@@ -117,9 +125,11 @@ ...@@ -117,9 +125,11 @@
# define alloc_func z_alloc_func # define alloc_func z_alloc_func
# define charf z_charf # define charf z_charf
# define free_func z_free_func # define free_func z_free_func
# define gzFile z_gzFile # ifndef Z_SOLO
# define gz_header z_gz_header # define gzFile z_gzFile
# define gz_headerp z_gz_headerp # define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# endif
# define in_func z_in_func # define in_func z_in_func
# define intf z_intf # define intf z_intf
# define out_func z_out_func # define out_func z_out_func
...@@ -132,7 +142,9 @@ ...@@ -132,7 +142,9 @@
# define voidpf z_voidpf # define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */ /* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s # ifndef Z_SOLO
# define gz_header_s z_gz_header_s
# endif
# define internal_state z_internal_state # define internal_state z_internal_state
#endif #endif
...@@ -379,7 +391,9 @@ typedef uLong FAR uLongf; ...@@ -379,7 +391,9 @@ typedef uLong FAR uLongf;
#endif #endif
#ifdef STDC #ifdef STDC
# include <sys/types.h> /* for off_t */ # ifndef Z_SOLO
# include <sys/types.h> /* for off_t */
# endif
#endif #endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
...@@ -396,7 +410,7 @@ typedef uLong FAR uLongf; ...@@ -396,7 +410,7 @@ typedef uLong FAR uLongf;
# define Z_LARGE # define Z_LARGE
#endif #endif
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) #if (defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)) && !defined(Z_SOLO)
# include <unistd.h> /* for SEEK_* and off_t */ # include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS # ifdef VMS
# include <unixio.h> /* for off_t */ # include <unixio.h> /* for off_t */
...@@ -406,7 +420,7 @@ typedef uLong FAR uLongf; ...@@ -406,7 +420,7 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#ifndef SEEK_SET #if !defined(SEEK_SET) && !defined(Z_SOLO)
# define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
......
...@@ -28,9 +28,11 @@ ...@@ -28,9 +28,11 @@
# define adler32 z_adler32 # define adler32 z_adler32
# define adler32_combine z_adler32_combine # define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64 # define adler32_combine64 z_adler32_combine64
# define compress z_compress # ifndef Z_SOLO
# define compress2 z_compress2 # define compress z_compress
# define compressBound z_compressBound # define compress2 z_compress2
# define compressBound z_compressBound
# endif
# define crc32 z_crc32 # define crc32 z_crc32
# define crc32_combine z_crc32_combine # define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64 # define crc32_combine64 z_crc32_combine64
...@@ -49,39 +51,41 @@ ...@@ -49,39 +51,41 @@
# define deflateTune z_deflateTune # define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright # define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table # define get_crc_table z_get_crc_table
# define gz_error z_gz_error # ifndef Z_SOLO
# define gz_intmax z_gz_intmax # define gz_error z_gz_error
# define gz_strwinerror z_gz_strwinerror # define gz_intmax z_gz_intmax
# define gzbuffer z_gzbuffer # define gz_strwinerror z_gz_strwinerror
# define gzclearerr z_gzclearerr # define gzbuffer z_gzbuffer
# define gzclose z_gzclose # define gzclearerr z_gzclearerr
# define gzclose_r z_gzclose_r # define gzclose z_gzclose
# define gzclose_w z_gzclose_w # define gzclose_r z_gzclose_r
# define gzdirect z_gzdirect # define gzclose_w z_gzclose_w
# define gzdopen z_gzdopen # define gzdirect z_gzdirect
# define gzeof z_gzeof # define gzdopen z_gzdopen
# define gzerror z_gzerror # define gzeof z_gzeof
# define gzflags z_gzflags # define gzerror z_gzerror
# define gzflush z_gzflush # define gzflags z_gzflags
# define gzgetc z_gzgetc # define gzflush z_gzflush
# define gzgetc_ z_gzgetc_ # define gzgetc z_gzgetc
# define gzgets z_gzgets # define gzgetc_ z_gzgetc_
# define gzoffset z_gzoffset # define gzgets z_gzgets
# define gzoffset64 z_gzoffset64 # define gzoffset z_gzoffset
# define gzopen z_gzopen # define gzoffset64 z_gzoffset64
# define gzopen64 z_gzopen64 # define gzopen z_gzopen
# define gzprintf z_gzprintf # define gzopen64 z_gzopen64
# define gzputc z_gzputc # define gzprintf z_gzprintf
# define gzputs z_gzputs # define gzputc z_gzputc
# define gzread z_gzread # define gzputs z_gzputs
# define gzrewind z_gzrewind # define gzread z_gzread
# define gzseek z_gzseek # define gzrewind z_gzrewind
# define gzseek64 z_gzseek64 # define gzseek z_gzseek
# define gzsetparams z_gzsetparams # define gzseek64 z_gzseek64
# define gztell z_gztell # define gzsetparams z_gzsetparams
# define gztell64 z_gztell64 # define gztell z_gztell
# define gzungetc z_gzungetc # define gztell64 z_gztell64
# define gzwrite z_gzwrite # define gzungetc z_gzungetc
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate # define inflate z_inflate
# define inflateBack z_inflateBack # define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd # define inflateBackEnd z_inflateBackEnd
...@@ -102,10 +106,14 @@ ...@@ -102,10 +106,14 @@
# define inflate_copyright z_inflate_copyright # define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast # define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table # define inflate_table z_inflate_table
# define uncompress z_uncompress # ifndef Z_SOLO
# define uncompress z_uncompress
# endif
# define zError z_zError # define zError z_zError
# define zcalloc z_zcalloc # ifndef Z_SOLO
# define zcfree z_zcfree # define zcalloc z_zcalloc
# define zcfree z_zcfree
# endif
# define zlibCompileFlags z_zlibCompileFlags # define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion # define zlibVersion z_zlibVersion
...@@ -115,9 +123,11 @@ ...@@ -115,9 +123,11 @@
# define alloc_func z_alloc_func # define alloc_func z_alloc_func
# define charf z_charf # define charf z_charf
# define free_func z_free_func # define free_func z_free_func
# define gzFile z_gzFile # ifndef Z_SOLO
# define gz_header z_gz_header # define gzFile z_gzFile
# define gz_headerp z_gz_headerp # define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# endif
# define in_func z_in_func # define in_func z_in_func
# define intf z_intf # define intf z_intf
# define out_func z_out_func # define out_func z_out_func
...@@ -130,7 +140,9 @@ ...@@ -130,7 +140,9 @@
# define voidpf z_voidpf # define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */ /* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s # ifndef Z_SOLO
# define gz_header_s z_gz_header_s
# endif
# define internal_state z_internal_state # define internal_state z_internal_state
#endif #endif
...@@ -377,7 +389,9 @@ typedef uLong FAR uLongf; ...@@ -377,7 +389,9 @@ typedef uLong FAR uLongf;
#endif #endif
#ifdef STDC #ifdef STDC
# include <sys/types.h> /* for off_t */ # ifndef Z_SOLO
# include <sys/types.h> /* for off_t */
# endif
#endif #endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and /* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
...@@ -394,7 +408,7 @@ typedef uLong FAR uLongf; ...@@ -394,7 +408,7 @@ typedef uLong FAR uLongf;
# define Z_LARGE # define Z_LARGE
#endif #endif
#if defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE) #if (defined(Z_HAVE_UNISTD_H) || defined(Z_LARGE)) && !defined(Z_SOLO)
# include <unistd.h> /* for SEEK_* and off_t */ # include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS # ifdef VMS
# include <unixio.h> /* for off_t */ # include <unixio.h> /* for off_t */
...@@ -404,7 +418,7 @@ typedef uLong FAR uLongf; ...@@ -404,7 +418,7 @@ typedef uLong FAR uLongf;
# endif # endif
#endif #endif
#ifndef SEEK_SET #if !defined(SEEK_SET) && !defined(Z_SOLO)
# define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
......
...@@ -1112,6 +1112,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); ...@@ -1112,6 +1112,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
27-31: 0 (reserved) 27-31: 0 (reserved)
*/ */
#ifndef Z_SOLO
/* utility functions */ /* utility functions */
...@@ -1176,7 +1177,6 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, ...@@ -1176,7 +1177,6 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
*/ */
/* gzip file access functions */ /* gzip file access functions */
/* /*
...@@ -1501,6 +1501,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); ...@@ -1501,6 +1501,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
file that is being written concurrently. file that is being written concurrently.
*/ */
#endif /* !Z_SOLO */
/* checksum functions */ /* checksum functions */
...@@ -1603,6 +1604,8 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, ...@@ -1603,6 +1604,8 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
inflateBackInit_((strm), (windowBits), (window), \ inflateBackInit_((strm), (windowBits), (window), \
ZLIB_VERSION, (int)sizeof(z_stream)) ZLIB_VERSION, (int)sizeof(z_stream))
#ifndef Z_SOLO
/* gzgetc() macro and its supporting function and exposed data structure. Note /* gzgetc() macro and its supporting function and exposed data structure. Note
* that the real internal state is much larger than the exposed structure. * that the real internal state is much larger than the exposed structure.
* This abbreviated structure exposes just enough for the gzgetc() macro. The * This abbreviated structure exposes just enough for the gzgetc() macro. The
...@@ -1667,6 +1670,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); ...@@ -1667,6 +1670,13 @@ ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
#endif #endif
#else /* Z_SOLO */
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
#endif /* !Z_SOLO */
/* hack for buggy compilers */ /* hack for buggy compilers */
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
struct internal_state {int dummy;}; struct internal_state {int dummy;};
...@@ -1677,7 +1687,9 @@ ZEXTERN const char * ZEXPORT zError OF((int)); ...@@ -1677,7 +1687,9 @@ ZEXTERN const char * ZEXPORT zError OF((int));
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN unsigned long ZEXPORT gzflags OF((void)); #ifndef Z_SOLO
ZEXTERN unsigned long ZEXPORT gzflags OF((void));
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -85,7 +85,11 @@ uLong ZEXPORT zlibCompileFlags() ...@@ -85,7 +85,11 @@ uLong ZEXPORT zlibCompileFlags()
#ifdef FASTEST #ifdef FASTEST
flags += 1L << 21; flags += 1L << 21;
#endif #endif
#ifdef Z_SOLO
return flags;
#else
return flags + gzflags(); return flags + gzflags();
#endif
} }
#ifdef DEBUG #ifdef DEBUG
...@@ -157,6 +161,7 @@ void ZLIB_INTERNAL zmemzero(dest, len) ...@@ -157,6 +161,7 @@ void ZLIB_INTERNAL zmemzero(dest, len)
} }
#endif #endif
#ifndef Z_SOLO
#ifdef SYS16BIT #ifdef SYS16BIT
...@@ -292,3 +297,5 @@ void ZLIB_INTERNAL zcfree (opaque, ptr) ...@@ -292,3 +297,5 @@ void ZLIB_INTERNAL zcfree (opaque, ptr)
} }
#endif /* MY_ZCALLOC */ #endif /* MY_ZCALLOC */
#endif /* !Z_SOLO */
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "zlib.h" #include "zlib.h"
#ifdef STDC #if defined(STDC) && !defined(Z_SOLO)
# if !(defined(_WIN32_WCE) && defined(_MSC_VER)) # if !(defined(_WIN32_WCE) && defined(_MSC_VER))
# include <stddef.h> # include <stddef.h>
# endif # endif
...@@ -29,6 +29,10 @@ ...@@ -29,6 +29,10 @@
# include <stdlib.h> # include <stdlib.h>
#endif #endif
#ifdef Z_SOLO
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
#endif
#ifndef local #ifndef local
# define local static # define local static
#endif #endif
...@@ -78,16 +82,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -78,16 +82,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00 # define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__) # ifndef Z_SOLO
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) # if defined(__TURBOC__) || defined(__BORLANDC__)
/* Allow compilation with ANSI keywords only enabled */ # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
void _Cdecl farfree( void *block ); /* Allow compilation with ANSI keywords only enabled */
void *_Cdecl farmalloc( unsigned long nbytes ); void _Cdecl farfree( void *block );
# else void *_Cdecl farmalloc( unsigned long nbytes );
# include <alloc.h> # else
# include <alloc.h>
# endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif # endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif # endif
#endif #endif
...@@ -107,18 +113,20 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -107,18 +113,20 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef OS2 #ifdef OS2
# define OS_CODE 0x06 # define OS_CODE 0x06
# ifdef M_I86 # if defined(M_I86) && !defined(Z_SOLO)
# include <malloc.h> # include <malloc.h>
# endif # endif
#endif #endif
#if defined(MACOS) || defined(TARGET_OS_MAC) #if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07 # define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os # ifndef Z_SOLO
# include <unix.h> /* for fdopen */ # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# else # include <unix.h> /* for fdopen */
# ifndef fdopen # else
# define fdopen(fd,mode) NULL /* No fdopen() */ # ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif # endif
# endif # endif
#endif #endif
...@@ -177,7 +185,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -177,7 +185,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* functions */ /* functions */
#if defined(pyr) #if defined(pyr) || defined(Z_SOLO)
# define NO_MEMCPY # define NO_MEMCPY
#endif #endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
...@@ -226,10 +234,11 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ ...@@ -226,10 +234,11 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define Tracecv(c,x) # define Tracecv(c,x)
#endif #endif
#ifndef Z_SOLO
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
unsigned size)); unsigned size));
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
#endif
#define ZALLOC(strm, items, size) \ #define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size)) (*((strm)->zalloc))((strm)->opaque, (items), (size))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册