Merge changes from vendor branch (1.1.1 -> 1.1.3) into mainline.

This commit is contained in:
Peter Wemm 1999-01-10 09:53:51 +00:00
parent 52454dcd09
commit 41d54c8049
13 changed files with 157 additions and 103 deletions

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $FreeBSD$ */ /* @(#) $Id$ */
#include "zlib.h" #include "zlib.h"

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $FreeBSD$ */ /* @(#) $Id$ */
#include "zlib.h" #include "zlib.h"

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $FreeBSD$ */ /* @(#) $Id$ */
#include "zlib.h" #include "zlib.h"

View File

@ -47,12 +47,12 @@
* *
*/ */
/* $FreeBSD$ */ /* @(#) $Id: deflate.c,v 1.1.1.3 1999/01/10 09:46:53 peter Exp $ */
#include "deflate.h" #include "deflate.h"
const char deflate_copyright[] = const char deflate_copyright[] =
" deflate 1.1.1 Copyright 1995-1998 Jean-loup Gailly "; " deflate 1.1.3 Copyright 1995-1998 Jean-loup Gailly ";
/* /*
If you use the zlib library in a product, an acknowledgment is welcome 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 in the documentation of your product. If for some reason you cannot
@ -608,11 +608,13 @@ int ZEXPORT deflateCopy (dest, source)
deflate_state *ss; deflate_state *ss;
ushf *overlay; ushf *overlay;
ss = source->state;
if (source == Z_NULL || dest == Z_NULL || ss == Z_NULL) { if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) {
return Z_STREAM_ERROR; return Z_STREAM_ERROR;
} }
ss = source->state;
*dest = *source; *dest = *source;
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));

View File

@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* $FreeBSD$ */ /* @(#) $Id: deflate.h,v 1.1.1.3 1999/01/10 09:46:53 peter Exp $ */
#ifndef _DEFLATE_H #ifndef _DEFLATE_H
#define _DEFLATE_H #define _DEFLATE_H
@ -230,12 +230,12 @@ typedef struct internal_state {
ulg opt_len; /* bit length of current block with optimal trees */ ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */ ulg static_len; /* bit length of current block with static trees */
ulg compressed_len; /* total bit length of compressed file */
uInt matches; /* number of string matches in current block */ uInt matches; /* number of string matches in current block */
int last_eob_len; /* bit length of EOB code for last block */ int last_eob_len; /* bit length of EOB code for last block */
#ifdef DEBUG #ifdef DEBUG
ulg bits_sent; /* bit length of the compressed data */ ulg compressed_len; /* total bit length of compressed file mod 2^32 */
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
#endif #endif
ush bi_buf; ush bi_buf;
@ -268,7 +268,7 @@ typedef struct internal_state {
/* in trees.c */ /* in trees.c */
void _tr_init OF((deflate_state *s)); void _tr_init OF((deflate_state *s));
int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); int _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc));
ulg _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len, void _tr_flush_block OF((deflate_state *s, charf *buf, ulg stored_len,
int eof)); int eof));
void _tr_align OF((deflate_state *s)); void _tr_align OF((deflate_state *s));
void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len, void _tr_stored_block OF((deflate_state *s, charf *buf, ulg stored_len,

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $FreeBSD$ */ /* @(#) $Id: example.c,v 1.1.1.3 1999/01/10 09:46:54 peter Exp $ */
#include <stdio.h> #include <stdio.h>
#include "zlib.h" #include "zlib.h"
@ -15,6 +15,12 @@
extern void exit OF((int)); extern void exit OF((int));
#endif #endif
#if defined(VMS) || defined(RISCOS)
# define TESTFILE "foo-gz"
#else
# define TESTFILE "foo.gz"
#endif
#define CHECK_ERR(err, msg) { \ #define CHECK_ERR(err, msg) { \
if (err != Z_OK) { \ if (err != Z_OK) { \
fprintf(stderr, "%s error: %d\n", msg, err); \ fprintf(stderr, "%s error: %d\n", msg, err); \
@ -71,7 +77,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
fprintf(stderr, "bad uncompress\n"); fprintf(stderr, "bad uncompress\n");
exit(1); exit(1);
} else { } else {
printf("uncompress(): %s\n", uncompr); printf("uncompress(): %s\n", (char *)uncompr);
} }
} }
@ -79,8 +85,8 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
* Test read/write of .gz files * Test read/write of .gz files
*/ */
void test_gzio(out, in, uncompr, uncomprLen) void test_gzio(out, in, uncompr, uncomprLen)
const char *out; /* output file */ const char *out; /* compressed output file */
const char *in; /* input file */ const char *in; /* compressed input file */
Byte *uncompr; Byte *uncompr;
int uncomprLen; int uncomprLen;
{ {
@ -121,13 +127,13 @@ void test_gzio(out, in, uncompr, uncomprLen)
fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); fprintf(stderr, "bad gzread: %s\n", (char*)uncompr);
exit(1); exit(1);
} else { } else {
printf("gzread(): %s\n", uncompr); printf("gzread(): %s\n", (char *)uncompr);
} }
pos = gzseek(file, -8L, SEEK_CUR); pos = gzseek(file, -8L, SEEK_CUR);
if (pos != 6 || gztell(file) != pos) { if (pos != 6 || gztell(file) != pos) {
fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n",
pos, gztell(file)); (long)pos, (long)gztell(file));
exit(1); exit(1);
} }
@ -146,7 +152,7 @@ void test_gzio(out, in, uncompr, uncomprLen)
fprintf(stderr, "bad gzgets after gzseek\n"); fprintf(stderr, "bad gzgets after gzseek\n");
exit(1); exit(1);
} else { } else {
printf("gzgets() after gzseek: %s\n", uncompr); printf("gzgets() after gzseek: %s\n", (char *)uncompr);
} }
gzclose(file); gzclose(file);
@ -227,7 +233,7 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
fprintf(stderr, "bad inflate\n"); fprintf(stderr, "bad inflate\n");
exit(1); exit(1);
} else { } else {
printf("inflate(): %s\n", uncompr); printf("inflate(): %s\n", (char *)uncompr);
} }
} }
@ -406,7 +412,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
err = inflateEnd(&d_stream); err = inflateEnd(&d_stream);
CHECK_ERR(err, "inflateEnd"); CHECK_ERR(err, "inflateEnd");
printf("after inflateSync(): hel%s\n", uncompr); printf("after inflateSync(): hel%s\n", (char *)uncompr);
} }
/* =========================================================================== /* ===========================================================================
@ -492,7 +498,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
fprintf(stderr, "bad inflate with dict\n"); fprintf(stderr, "bad inflate with dict\n");
exit(1); exit(1);
} else { } else {
printf("inflate with dictionary: %s\n", uncompr); printf("inflate with dictionary: %s\n", (char *)uncompr);
} }
} }
@ -528,8 +534,8 @@ int main(argc, argv)
} }
test_compress(compr, comprLen, uncompr, uncomprLen); test_compress(compr, comprLen, uncompr, uncomprLen);
test_gzio((argc > 1 ? argv[1] : "foo.gz"), test_gzio((argc > 1 ? argv[1] : TESTFILE),
(argc > 2 ? argv[2] : "foo.gz"), (argc > 2 ? argv[2] : TESTFILE),
uncompr, (int)uncomprLen); uncompr, (int)uncomprLen);
test_deflate(compr, comprLen); test_deflate(compr, comprLen);

View File

@ -5,7 +5,7 @@
* Compile this file with -DNO_DEFLATE to avoid the compression code. * Compile this file with -DNO_DEFLATE to avoid the compression code.
*/ */
/* $FreeBSD$ */ /* @(#) $Id: gzio.c,v 1.1.1.3 1999/01/10 09:46:54 peter Exp $ */
#include <stdio.h> #include <stdio.h>
@ -13,8 +13,16 @@
struct internal_state {int dummy;}; /* for buggy compilers */ struct internal_state {int dummy;}; /* for buggy compilers */
#define Z_BUFSIZE 16384 #ifndef Z_BUFSIZE
#define Z_PRINTF_BUFSIZE 4096 # ifdef MAXSEG_64K
# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */
# else
# define Z_BUFSIZE 16384
# endif
#endif
#ifndef Z_PRINTF_BUFSIZE
# define Z_PRINTF_BUFSIZE 4096
#endif
#define ALLOC(size) malloc(size) #define ALLOC(size) malloc(size)
#define TRYFREE(p) {if (p) free(p);} #define TRYFREE(p) {if (p) free(p);}
@ -132,8 +140,12 @@ local gzFile gz_open (path, mode, fd)
s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE);
err = inflateInit2(&(s->stream), -MAX_WBITS); err = inflateInit2(&(s->stream), -MAX_WBITS);
/* windowBits is passed < 0 to tell that there is no zlib header */ /* windowBits is passed < 0 to tell that there is no zlib header.
* Note that in this case inflate *requires* an extra "dummy" byte
* after the compressed stream in order to complete decompression and
* return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are
* present after the compressed stream.
*/
if (err != Z_OK || s->inbuf == Z_NULL) { if (err != Z_OK || s->inbuf == Z_NULL) {
return destroy(s), (gzFile)Z_NULL; return destroy(s), (gzFile)Z_NULL;
} }
@ -379,6 +391,7 @@ int ZEXPORT gzread (file, buf, len)
len -= s->stream.avail_out; len -= s->stream.avail_out;
s->stream.total_in += (uLong)len; s->stream.total_in += (uLong)len;
s->stream.total_out += (uLong)len; s->stream.total_out += (uLong)len;
if (len == 0) s->z_eof = 1;
return (int)len; return (int)len;
} }
if (s->stream.avail_in == 0 && !s->z_eof) { if (s->stream.avail_in == 0 && !s->z_eof) {
@ -401,10 +414,14 @@ int ZEXPORT gzread (file, buf, len)
s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start));
start = s->stream.next_out; start = s->stream.next_out;
if (getLong(s) != s->crc || getLong(s) != s->stream.total_out) { if (getLong(s) != s->crc) {
s->z_err = Z_DATA_ERROR; s->z_err = Z_DATA_ERROR;
} else { } else {
/* Check for concatenated .gz files: */ (void)getLong(s);
/* The uncompressed length returned by above getlong() may
* be different from s->stream.total_out) in case of
* concatenated .gz files. Check for such files:
*/
check_header(s); check_header(s);
if (s->z_err == Z_OK) { if (s->z_err == Z_OK) {
uLong total_in = s->stream.total_in; uLong total_in = s->stream.total_in;
@ -572,7 +589,7 @@ int ZEXPORT gzputs(file, s)
gzFile file; gzFile file;
const char *s; const char *s;
{ {
return gzwrite(file, (const voidp)s, (unsigned)strlen(s)); return gzwrite(file, (char*)s, (unsigned)strlen(s));
} }
@ -657,7 +674,7 @@ z_off_t ZEXPORT gzseek (file, offset, whence)
return -1L; return -1L;
#else #else
if (whence == SEEK_SET) { if (whence == SEEK_SET) {
offset -= s->stream.total_out; offset -= s->stream.total_in;
} }
if (offset < 0) return -1L; if (offset < 0) return -1L;
@ -732,6 +749,7 @@ int ZEXPORT gzrewind (file)
s->z_eof = 0; s->z_eof = 0;
s->stream.avail_in = 0; s->stream.avail_in = 0;
s->stream.next_in = s->inbuf; s->stream.next_in = s->inbuf;
s->crc = crc32(0L, Z_NULL, 0);
if (s->startpos == 0) { /* not a compressed file */ if (s->startpos == 0) { /* not a compressed file */
rewind(s->file); rewind(s->file);
@ -780,7 +798,8 @@ local void putLong (file, x)
} }
/* =========================================================================== /* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets Reads a long in LSB order from the given gz_stream. Sets z_err in case
of error.
*/ */
local uLong getLong (s) local uLong getLong (s)
gz_stream *s; gz_stream *s;

View File

@ -13,7 +13,7 @@
* or in pipe mode. * or in pipe mode.
*/ */
/* $FreeBSD$ */ /* @(#) $Id: minigzip.c,v 1.1.1.3 1999/01/10 09:46:57 peter Exp $ */
#include <stdio.h> #include <stdio.h>
#include "zlib.h" #include "zlib.h"
@ -48,6 +48,9 @@
# define GZ_SUFFIX "-gz" # define GZ_SUFFIX "-gz"
# define fileno(file) file->__file # define fileno(file) file->__file
#endif #endif
#if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fileno */
#endif
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */ #ifndef WIN32 /* unlink already in stdio.h for WIN32 */
extern int unlink OF((const char *)); extern int unlink OF((const char *));

View File

@ -29,7 +29,7 @@
* Addison-Wesley, 1983. ISBN 0-201-06672-6. * Addison-Wesley, 1983. ISBN 0-201-06672-6.
*/ */
/* $FreeBSD$ */ /* @(#) $Id: trees.c,v 1.1.1.3 1999/01/10 09:46:57 peter Exp $ */
/* #define GEN_TREES_H */ /* #define GEN_TREES_H */
@ -250,6 +250,13 @@ local void tr_static_init()
if (static_init_done) return; if (static_init_done) return;
/* For some embedded targets, global variables are not initialized: */
static_l_desc.static_tree = static_ltree;
static_l_desc.extra_bits = extra_lbits;
static_d_desc.static_tree = static_dtree;
static_d_desc.extra_bits = extra_dbits;
static_bl_desc.extra_bits = extra_blbits;
/* Initialize the mapping length (0..255) -> length code (0..28) */ /* Initialize the mapping length (0..255) -> length code (0..28) */
length = 0; length = 0;
for (code = 0; code < LENGTH_CODES-1; code++) { for (code = 0; code < LENGTH_CODES-1; code++) {
@ -378,8 +385,6 @@ void _tr_init(s)
{ {
tr_static_init(); tr_static_init();
s->compressed_len = 0L;
s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.dyn_tree = s->dyn_ltree;
s->l_desc.stat_desc = &static_l_desc; s->l_desc.stat_desc = &static_l_desc;
@ -393,6 +398,7 @@ void _tr_init(s)
s->bi_valid = 0; s->bi_valid = 0;
s->last_eob_len = 8; /* enough lookahead for inflate */ s->last_eob_len = 8; /* enough lookahead for inflate */
#ifdef DEBUG #ifdef DEBUG
s->compressed_len = 0L;
s->bits_sent = 0L; s->bits_sent = 0L;
#endif #endif
@ -865,9 +871,10 @@ void _tr_stored_block(s, buf, stored_len, eof)
int eof; /* true if this is the last block for a file */ int eof; /* true if this is the last block for a file */
{ {
send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */ send_bits(s, (STORED_BLOCK<<1)+eof, 3); /* send block type */
#ifdef DEBUG
s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L;
s->compressed_len += (stored_len + 4) << 3; s->compressed_len += (stored_len + 4) << 3;
#endif
copy_block(s, buf, (unsigned)stored_len, 1); /* with header */ copy_block(s, buf, (unsigned)stored_len, 1); /* with header */
} }
@ -887,7 +894,9 @@ void _tr_align(s)
{ {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG
s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ s->compressed_len += 10L; /* 3 for block type, 7 for EOB */
#endif
bi_flush(s); bi_flush(s);
/* Of the 10 bits for the empty block, we have already sent /* Of the 10 bits for the empty block, we have already sent
* (10 - bi_valid) bits. The lookahead for the last real code (before * (10 - bi_valid) bits. The lookahead for the last real code (before
@ -897,7 +906,9 @@ void _tr_align(s)
if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { if (1 + s->last_eob_len + 10 - s->bi_valid < 9) {
send_bits(s, STATIC_TREES<<1, 3); send_bits(s, STATIC_TREES<<1, 3);
send_code(s, END_BLOCK, static_ltree); send_code(s, END_BLOCK, static_ltree);
#ifdef DEBUG
s->compressed_len += 10L; s->compressed_len += 10L;
#endif
bi_flush(s); bi_flush(s);
} }
s->last_eob_len = 7; s->last_eob_len = 7;
@ -905,10 +916,9 @@ void _tr_align(s)
/* =========================================================================== /* ===========================================================================
* Determine the best encoding for the current block: dynamic trees, static * Determine the best encoding for the current block: dynamic trees, static
* trees or store, and output the encoded block to the zip file. This function * trees or store, and output the encoded block to the zip file.
* returns the total compressed length for the file so far.
*/ */
ulg _tr_flush_block(s, buf, stored_len, eof) void _tr_flush_block(s, buf, stored_len, eof)
deflate_state *s; deflate_state *s;
charf *buf; /* input block, or NULL if too old */ charf *buf; /* input block, or NULL if too old */
ulg stored_len; /* length of input block */ ulg stored_len; /* length of input block */
@ -955,25 +965,6 @@ ulg _tr_flush_block(s, buf, stored_len, eof)
opt_lenb = static_lenb = stored_len + 5; /* force a stored block */ opt_lenb = static_lenb = stored_len + 5; /* force a stored block */
} }
/* If compression failed and this is the first and last block,
* and if the .zip file can be seeked (to rewrite the local header),
* the whole file is transformed into a stored file:
*/
#ifdef STORED_FILE_OK
# ifdef FORCE_STORED_FILE
if (eof && s->compressed_len == 0L) { /* force stored file */
# else
if (stored_len <= opt_lenb && eof && s->compressed_len==0L && seekable()) {
# endif
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (charf*)0) error ("block vanished");
copy_block(buf, (unsigned)stored_len, 0); /* without header */
s->compressed_len = stored_len << 3;
s->method = STORED;
} else
#endif /* STORED_FILE_OK */
#ifdef FORCE_STORED #ifdef FORCE_STORED
if (buf != (char*)0) { /* force stored block */ if (buf != (char*)0) { /* force stored block */
#else #else
@ -995,25 +986,32 @@ ulg _tr_flush_block(s, buf, stored_len, eof)
#endif #endif
send_bits(s, (STATIC_TREES<<1)+eof, 3); send_bits(s, (STATIC_TREES<<1)+eof, 3);
compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree); compress_block(s, (ct_data *)static_ltree, (ct_data *)static_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->static_len; s->compressed_len += 3 + s->static_len;
#endif
} else { } else {
send_bits(s, (DYN_TREES<<1)+eof, 3); send_bits(s, (DYN_TREES<<1)+eof, 3);
send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1, send_all_trees(s, s->l_desc.max_code+1, s->d_desc.max_code+1,
max_blindex+1); max_blindex+1);
compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree); compress_block(s, (ct_data *)s->dyn_ltree, (ct_data *)s->dyn_dtree);
#ifdef DEBUG
s->compressed_len += 3 + s->opt_len; s->compressed_len += 3 + s->opt_len;
#endif
} }
Assert (s->compressed_len == s->bits_sent, "bad compressed size"); Assert (s->compressed_len == s->bits_sent, "bad compressed size");
/* The above check is made mod 2^32, for files larger than 512 MB
* and uLong implemented on 32 bits.
*/
init_block(s); init_block(s);
if (eof) { if (eof) {
bi_windup(s); bi_windup(s);
#ifdef DEBUG
s->compressed_len += 7; /* align on byte boundary */ s->compressed_len += 7; /* align on byte boundary */
#endif
} }
Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3, Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len>>3,
s->compressed_len-7*eof)); s->compressed_len-7*eof));
return s->compressed_len >> 3;
} }
/* =========================================================================== /* ===========================================================================

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $FreeBSD$ */ /* @(#) $Id$ */
#include "zlib.h" #include "zlib.h"

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $FreeBSD$ */ /* @(#) $Id: zconf.h,v 1.1.1.3 1999/01/10 09:46:58 peter Exp $ */
#ifndef _ZCONF_H #ifndef _ZCONF_H
#define _ZCONF_H #define _ZCONF_H
@ -91,8 +91,8 @@
# define NO_DUMMY_DECL # define NO_DUMMY_DECL
#endif #endif
/* Borland C incorrectly complains about missing returns: */ /* Old Borland C incorrectly complains about missing returns: */
#if defined(__BORLANDC__) #if defined(__BORLANDC__) && (__BORLANDC__ < 0x500)
# define NEED_DUMMY_RETURN # define NEED_DUMMY_RETURN
#endif #endif
@ -148,7 +148,7 @@
/* MSC small or medium model */ /* MSC small or medium model */
# define SMALL_MEDIUM # define SMALL_MEDIUM
# ifdef _MSC_VER # ifdef _MSC_VER
# define FAR __far # define FAR _far
# else # else
# define FAR far # define FAR far
# endif # endif
@ -156,42 +156,68 @@
#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) #if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__))
# ifndef __32BIT__ # ifndef __32BIT__
# define SMALL_MEDIUM # define SMALL_MEDIUM
# define FAR __far # define FAR _far
# endif # endif
#endif #endif
/* Compile with -DZLIB_DLL for Windows DLL support */ /* Compile with -DZLIB_DLL for Windows DLL support */
#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) #if defined(ZLIB_DLL)
# ifdef FAR # if defined(_WINDOWS) || defined(WINDOWS)
# undef FAR # ifdef FAR
# undef FAR
# endif
# include <windows.h>
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR _cdecl _export
# endif
# endif # endif
# include <windows.h> # if defined (__BORLANDC__)
# define ZEXPORT WINAPI # if (__BORLANDC__ >= 0x0500) && defined (WIN32)
# ifdef WIN32 # include <windows.h>
# define ZEXPORTVA WINAPIV # define ZEXPORT __declspec(dllexport) WINAPI
# define ZEXPORTRVA __declspec(dllexport) WINAPIV
# else
# if defined (_Windows) && defined (__DLL__)
# define ZEXPORT _export
# define ZEXPORTVA _export
# endif
# endif
# endif
#endif
#if defined (__BEOS__)
# if defined (ZLIB_DLL)
# define ZEXTERN extern __declspec(dllexport)
# else # else
# define ZEXPORTVA FAR _cdecl _export # define ZEXTERN extern __declspec(dllimport)
# endif # endif
#else #endif
# if defined (__BORLANDC__) && defined (_Windows) && defined (__DLL__)
# define ZEXPORT _export #ifndef ZEXPORT
# define ZEXPORTVA _export # define ZEXPORT
# else #endif
# define ZEXPORT #ifndef ZEXPORTVA
# define ZEXPORTVA # define ZEXPORTVA
# endif #endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif #endif
#ifndef FAR #ifndef FAR
# define FAR # define FAR
#endif #endif
#if !defined(MACOS) && !defined(TARGET_OS_MAC)
typedef unsigned char Byte; /* 8 bits */ typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */ typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */ typedef unsigned long uLong; /* 32 bits or more */
#if defined(__BORLANDC__) && defined(SMALL_MEDIUM) #ifdef SMALL_MEDIUM
/* Borland C/C++ ignores FAR inside typedef */ /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR # define Bytef Byte FAR
#else #else
typedef Byte FAR Bytef; typedef Byte FAR Bytef;
@ -217,6 +243,7 @@ typedef uLong FAR uLongf;
#ifndef SEEK_SET #ifndef SEEK_SET
# 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" */
#endif #endif
#ifndef z_off_t #ifndef z_off_t
# define z_off_t long # define z_off_t long

View File

@ -3,7 +3,7 @@
* For conditions of distribution and use, see copyright notice in zlib.h * For conditions of distribution and use, see copyright notice in zlib.h
*/ */
/* $FreeBSD$ */ /* @(#) $Id: zutil.c,v 1.1.1.3 1999/01/10 09:46:59 peter Exp $ */
#include "zutil.h" #include "zutil.h"
@ -60,7 +60,7 @@ const char * ZEXPORT zError(err)
void zmemcpy(dest, source, len) void zmemcpy(dest, source, len)
Bytef* dest; Bytef* dest;
Bytef* source; const Bytef* source;
uInt len; uInt len;
{ {
if (len == 0) return; if (len == 0) return;
@ -70,8 +70,8 @@ void zmemcpy(dest, source, len)
} }
int zmemcmp(s1, s2, len) int zmemcmp(s1, s2, len)
Bytef* s1; const Bytef* s1;
Bytef* s2; const Bytef* s2;
uInt len; uInt len;
{ {
uInt j; uInt j;
@ -178,7 +178,7 @@ void zcfree (voidpf opaque, voidpf ptr)
# define MY_ZCALLOC # define MY_ZCALLOC
#if (!defined(_MSC_VER) || (_MSC_VER < 600)) #if (!defined(_MSC_VER) || (_MSC_VER <= 600))
# define _halloc halloc # define _halloc halloc
# define _hfree hfree # define _hfree hfree
#endif #endif

View File

@ -8,7 +8,7 @@
subject to change. Applications should only use zlib.h. subject to change. Applications should only use zlib.h.
*/ */
/* $FreeBSD$ */ /* @(#) $Id: zutil.h,v 1.1.1.3 1999/01/10 09:46:59 peter Exp $ */
#ifndef _Z_UTIL_H #ifndef _Z_UTIL_H
#define _Z_UTIL_H #define _Z_UTIL_H
@ -75,7 +75,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef MSDOS #ifdef MSDOS
# define OS_CODE 0x00 # define OS_CODE 0x00
# ifdef __TURBOC__ # if defined(__TURBOC__) || defined(__BORLANDC__)
# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */ /* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block ); void _Cdecl farfree( void *block );
@ -112,13 +112,12 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(MACOS) || defined(TARGET_OS_MAC) #if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07 # define OS_CODE 0x07
# ifndef fdopen # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# define fdopen(fd,mode) NULL /* No fdopen() */ # include <unix.h> /* for fdopen */
# endif # else
#endif # ifndef fdopen
#if defined(__MWERKS__) && !defined(fdopen) # define fdopen(fd,mode) NULL /* No fdopen() */
# if __dest_os != __be_os && __dest_os != __win32_os # endif
# define fdopen(fd,mode) NULL
# endif # endif
#endif #endif
@ -134,7 +133,7 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define fdopen(fd,mode) NULL /* No fdopen() */ # define fdopen(fd,mode) NULL /* No fdopen() */
#endif #endif
#if (defined(_MSC_VER) && (_MSC_VER >= 600)) #if (defined(_MSC_VER) && (_MSC_VER > 600))
# define fdopen(fd,type) _fdopen(fd,type) # define fdopen(fd,type) _fdopen(fd,type)
#endif #endif
@ -182,8 +181,8 @@ extern const char *z_errmsg[10]; /* indexed by 2-zlib_error */
# define zmemzero(dest, len) memset(dest, 0, len) # define zmemzero(dest, len) memset(dest, 0, len)
# endif # endif
#else #else
extern void zmemcpy OF((Bytef* dest, Bytef* source, uInt len)); extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
extern int zmemcmp OF((Bytef* s1, Bytef* s2, uInt len)); extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
extern void zmemzero OF((Bytef* dest, uInt len)); extern void zmemzero OF((Bytef* dest, uInt len));
#endif #endif