1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-30 22:23:13 +03:00

zlibWrapper: convert to C89 / ANSI C

Clang 16 (which is the system compiler in FreeBSD 14.0) no longer allows
K&R function definitions.  Formatting of the changes matches current
zlib.
This commit is contained in:
Ed Maste
2023-12-13 19:54:29 -05:00
parent 86ead9f4a4
commit 2ce0290e4d
7 changed files with 103 additions and 324 deletions

View File

@ -77,9 +77,7 @@ int main _Z_OF((int argc, char *argv[]));
void *myalloc _Z_OF((void *, unsigned, unsigned)); void *myalloc _Z_OF((void *, unsigned, unsigned));
void myfree _Z_OF((void *, void *)); void myfree _Z_OF((void *, void *));
void *myalloc(q, n, m) void *myalloc(void *q, unsigned n, unsigned m)
void *q;
unsigned n, m;
{ {
void *buf = calloc(n, m); void *buf = calloc(n, m);
q = Z_NULL; q = Z_NULL;
@ -110,10 +108,8 @@ void test_gzio _Z_OF((const char *fname,
/* =========================================================================== /* ===========================================================================
* Test compress() and uncompress() * Test compress() and uncompress()
*/ */
void test_compress(compr, comprLen, uncompr, uncomprLen) void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen) {
uLong comprLen, uncomprLen;
{
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello)+1;
@ -136,11 +132,7 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test read/write of .gz files * Test read/write of .gz files
*/ */
void test_gzio(fname, uncompr, uncomprLen) void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
const char *fname; /* compressed file name */
Byte *uncompr;
uLong uncomprLen;
{
#ifdef NO_GZCOMPRESS #ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else #else
@ -222,10 +214,7 @@ void test_gzio(fname, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with small buffers * Test deflate() with small buffers
*/ */
void test_deflate(compr, comprLen) void test_deflate(Byte *compr, uLong comprLen) {
Byte *compr;
uLong comprLen;
{
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello)+1;
@ -260,10 +249,8 @@ void test_deflate(compr, comprLen)
/* =========================================================================== /* ===========================================================================
* Test inflate() with small buffers * Test inflate() with small buffers
*/ */
void test_inflate(compr, comprLen, uncompr, uncomprLen) void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen) {
uLong comprLen, uncomprLen;
{
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -301,10 +288,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level * Test deflate() with large buffers and dynamic change of compression level
*/ */
void test_large_deflate(compr, comprLen, uncompr, uncomprLen) void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen) {
uLong comprLen, uncomprLen;
{
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -356,10 +341,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test inflate() with large buffers * Test inflate() with large buffers
*/ */
void test_large_inflate(compr, comprLen, uncompr, uncomprLen) void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen) {
uLong comprLen, uncomprLen;
{
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -397,10 +380,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with full flush * Test deflate() with full flush
*/ */
void test_flush(compr, comprLen) void test_flush(Byte *compr, uLong *comprLen) {
Byte *compr;
uLong *comprLen;
{
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
uInt len = (uInt)strlen(hello)+1; uInt len = (uInt)strlen(hello)+1;
@ -435,10 +415,7 @@ void test_flush(compr, comprLen)
/* =========================================================================== /* ===========================================================================
* Test inflateSync() * Test inflateSync()
*/ */
void test_sync(compr, comprLen, uncompr, uncomprLen) void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -479,10 +456,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with preset dictionary * Test deflate() with preset dictionary
*/ */
void test_dict_deflate(compr, comprLen) void test_dict_deflate(Byte *compr, uLong comprLen) {
Byte *compr;
uLong comprLen;
{
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -516,10 +490,8 @@ void test_dict_deflate(compr, comprLen)
/* =========================================================================== /* ===========================================================================
* Test inflate() with a preset dictionary * Test inflate() with a preset dictionary
*/ */
void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen) {
uLong comprLen, uncomprLen;
{
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -567,10 +539,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
* Usage: example [output.gz [input.gz]] * Usage: example [output.gz [input.gz]]
*/ */
int main(argc, argv) int main(int argc, char *argv[]) {
int argc;
char *argv[];
{
Byte *compr, *uncompr; Byte *compr, *uncompr;
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */
uLong uncomprLen = comprLen; uLong uncomprLen = comprLen;

View File

@ -102,9 +102,7 @@ void test_gzio _Z_OF((const char *fname,
/* =========================================================================== /* ===========================================================================
* Test compress() and uncompress() * Test compress() and uncompress()
*/ */
void test_compress(compr, comprLen, uncompr, uncomprLen) void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{ {
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello)+1;
@ -128,10 +126,8 @@ void test_compress(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test read/write of .gz files * Test read/write of .gz files
*/ */
void test_gzio(fname, uncompr, uncomprLen) void test_gzio(const char *fname /* compressed file name */, Byte *uncompr,
const char *fname; /* compressed file name */ uLong uncomprLen)
Byte *uncompr;
uLong uncomprLen;
{ {
#ifdef NO_GZCOMPRESS #ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
@ -214,9 +210,7 @@ void test_gzio(fname, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with small buffers * Test deflate() with small buffers
*/ */
void test_deflate(compr, comprLen) void test_deflate(Byte *compr, uLong comprLen)
Byte *compr;
uLong comprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -252,9 +246,7 @@ void test_deflate(compr, comprLen)
/* =========================================================================== /* ===========================================================================
* Test inflate() with small buffers * Test inflate() with small buffers
*/ */
void test_inflate(compr, comprLen, uncompr, uncomprLen) void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -293,9 +285,8 @@ void test_inflate(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level * Test deflate() with large buffers and dynamic change of compression level
*/ */
void test_large_deflate(compr, comprLen, uncompr, uncomprLen) void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen)
uLong comprLen, uncomprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -348,9 +339,8 @@ void test_large_deflate(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test inflate() with large buffers * Test inflate() with large buffers
*/ */
void test_large_inflate(compr, comprLen, uncompr, uncomprLen) void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen)
uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -389,9 +379,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with full flush * Test deflate() with full flush
*/ */
void test_flush(compr, comprLen) void test_flush(Byte *compr, uLong comprLen)
Byte *compr;
uLong *comprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -427,9 +415,7 @@ void test_flush(compr, comprLen)
/* =========================================================================== /* ===========================================================================
* Test inflateSync() * Test inflateSync()
*/ */
void test_sync(compr, comprLen, uncompr, uncomprLen) void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen)
Byte *compr, *uncompr;
uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -471,9 +457,7 @@ void test_sync(compr, comprLen, uncompr, uncomprLen)
/* =========================================================================== /* ===========================================================================
* Test deflate() with preset dictionary * Test deflate() with preset dictionary
*/ */
void test_dict_deflate(compr, comprLen) void test_dict_deflate(Byte *compr, uLong comprLen)
Byte *compr;
uLong comprLen;
{ {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -508,9 +492,8 @@ void test_dict_deflate(compr, comprLen)
/* =========================================================================== /* ===========================================================================
* Test inflate() with a preset dictionary * Test inflate() with a preset dictionary
*/ */
void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
Byte *compr, *uncompr; uLong uncomprLen)
uLong comprLen, uncomprLen;
{ {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -559,9 +542,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen)
* Usage: example [output.gz [input.gz]] * Usage: example [output.gz [input.gz]]
*/ */
int main(argc, argv) int main(int argc, char *argv[])
int argc;
char *argv[];
{ {
Byte *compr, *uncompr; Byte *compr, *uncompr;
uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */

View File

@ -82,8 +82,7 @@
The strwinerror function does not change the current setting The strwinerror function does not change the current setting
of GetLastError. */ of GetLastError. */
static char *strwinerror (error) static char *strwinerror(DWORD error)
DWORD error;
{ {
static char buf[1024]; static char buf[1024];
@ -121,8 +120,7 @@ static char *strwinerror (error)
return buf; return buf;
} }
static void pwinerror (s) static void pwinerror (const char *s)
const char *s;
{ {
if (s && *s) if (s && *s)
fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ())); fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ()));
@ -198,11 +196,7 @@ const char *mode;
return gz_open(NULL, fd, mode); return gz_open(NULL, fd, mode);
} }
gzFile gz_open(path, fd, mode) gzFile gz_open(const char *path, int fd, const char *mode) {
const char *path;
int fd;
const char *mode;
{
gzFile gz; gzFile gz;
int ret; int ret;
@ -238,11 +232,7 @@ gzFile gz_open(path, fd, mode)
int gzwrite _Z_OF((gzFile, const void *, unsigned)); int gzwrite _Z_OF((gzFile, const void *, unsigned));
int gzwrite(gz, buf, len) int gzwrite(gzFile gz, const void *buf, unsigned len) {
gzFile gz;
const void *buf;
unsigned len;
{
z_stream *strm; z_stream *strm;
unsigned char out[BUFLEN]; unsigned char out[BUFLEN];
@ -262,11 +252,7 @@ int gzwrite(gz, buf, len)
int gzread _Z_OF((gzFile, void *, unsigned)); int gzread _Z_OF((gzFile, void *, unsigned));
int gzread(gz, buf, len) int gzread(gzFile gz, void *buf, unsigned len) {
gzFile gz;
void *buf;
unsigned len;
{
int ret; int ret;
unsigned got; unsigned got;
unsigned char in[1]; unsigned char in[1];
@ -299,9 +285,7 @@ int gzread(gz, buf, len)
int gzclose _Z_OF((gzFile)); int gzclose _Z_OF((gzFile));
int gzclose(gz) int gzclose(gzFile gz) {
gzFile gz;
{
z_stream *strm; z_stream *strm;
unsigned char out[BUFLEN]; unsigned char out[BUFLEN];
@ -328,9 +312,7 @@ int gzclose(gz)
const char *gzerror _Z_OF((gzFile, int *)); const char *gzerror _Z_OF((gzFile, int *));
const char *gzerror(gz, err) const char *gzerror(gzFile gz, int *err)
gzFile gz;
int *err;
{ {
*err = gz->err; *err = gz->err;
return gz->msg; return gz->msg;
@ -353,8 +335,7 @@ int main _Z_OF((int argc, char *argv[]));
/* =========================================================================== /* ===========================================================================
* Display error message and exit * Display error message and exit
*/ */
void error(msg) void error(const char *msg)
const char *msg;
{ {
fprintf(stderr, "%s: %s\n", prog, msg); fprintf(stderr, "%s: %s\n", prog, msg);
exit(1); exit(1);
@ -364,9 +345,7 @@ void error(msg)
* Compress input to output then close both files. * Compress input to output then close both files.
*/ */
void gz_compress(in, out) void gz_compress(FILE *in, gzFile out)
FILE *in;
gzFile out;
{ {
local char buf[BUFLEN]; local char buf[BUFLEN];
int len; int len;
@ -397,10 +376,7 @@ void gz_compress(in, out)
/* Try compressing the input file at once using mmap. Return Z_OK if /* Try compressing the input file at once using mmap. Return Z_OK if
* if success, Z_ERRNO otherwise. * if success, Z_ERRNO otherwise.
*/ */
int gz_compress_mmap(in, out) int gz_compress_mmap(FILE *in, gzFile out) {
FILE *in;
gzFile out;
{
int len; int len;
int err; int err;
int ifd = fileno(in); int ifd = fileno(in);
@ -432,10 +408,7 @@ int gz_compress_mmap(in, out)
/* =========================================================================== /* ===========================================================================
* Uncompress input to output then close both files. * Uncompress input to output then close both files.
*/ */
void gz_uncompress(in, out) void gz_uncompress(gzFile in, FILE *out) {
gzFile in;
FILE *out;
{
local char buf[BUFLEN]; local char buf[BUFLEN];
int len; int len;
int err; int err;
@ -459,10 +432,7 @@ void gz_uncompress(in, out)
* Compress the given file: create a corresponding .gz file and remove the * Compress the given file: create a corresponding .gz file and remove the
* original. * original.
*/ */
void file_compress(file, mode) void file_compress(char *file, char *mode) {
char *file;
char *mode;
{
local char outfile[MAX_NAME_LEN]; local char outfile[MAX_NAME_LEN];
FILE *in; FILE *in;
gzFile out; gzFile out;
@ -494,9 +464,7 @@ void file_compress(file, mode)
/* =========================================================================== /* ===========================================================================
* Uncompress the given file and remove the original. * Uncompress the given file and remove the original.
*/ */
void file_uncompress(file) void file_uncompress(char *file) {
char *file;
{
local char buf[MAX_NAME_LEN]; local char buf[MAX_NAME_LEN];
char *infile, *outfile; char *infile, *outfile;
FILE *out; FILE *out;
@ -546,10 +514,7 @@ void file_uncompress(file)
* -1 to -9 : compression level * -1 to -9 : compression level
*/ */
int main(argc, argv) int main(int argc, char *argv[]) {
int argc;
char *argv[];
{
int copyout = 0; int copyout = 0;
int uncompr = 0; int uncompr = 0;
gzFile file; gzFile file;

View File

@ -11,9 +11,7 @@
/* gzclose() is in a separate file so that it is linked in only if it is used. /* gzclose() is in a separate file so that it is linked in only if it is used.
That way the other gzclose functions can be used instead to avoid linking in That way the other gzclose functions can be used instead to avoid linking in
unneeded compression or decompression routines. */ unneeded compression or decompression routines. */
int ZEXPORT gzclose(file) int ZEXPORT gzclose(gzFile file) {
gzFile file;
{
#ifndef NO_GZCOMPRESS #ifndef NO_GZCOMPRESS
gz_statep state; gz_statep state;

View File

@ -33,9 +33,7 @@ local gzFile gz_open _Z_OF((const void *, int, const char *));
The gz_strwinerror function does not change the current setting of The gz_strwinerror function does not change the current setting of
GetLastError. */ GetLastError. */
char ZLIB_INTERNAL *gz_strwinerror (error) char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
DWORD error;
{
static char buf[1024]; static char buf[1024];
wchar_t *msgbuf; wchar_t *msgbuf;
@ -75,9 +73,7 @@ char ZLIB_INTERNAL *gz_strwinerror (error)
#endif /* UNDER_CE */ #endif /* UNDER_CE */
/* Reset gzip file state */ /* Reset gzip file state */
local void gz_reset(state) local void gz_reset(gz_statep state) {
gz_statep state;
{
state.state->x.have = 0; /* no output data available */ state.state->x.have = 0; /* no output data available */
if (state.state->mode == GZ_READ) { /* for reading ... */ if (state.state->mode == GZ_READ) { /* for reading ... */
state.state->eof = 0; /* not at end of file */ state.state->eof = 0; /* not at end of file */
@ -91,11 +87,7 @@ local void gz_reset(state)
} }
/* Open a gzip file either by name or file descriptor. */ /* Open a gzip file either by name or file descriptor. */
local gzFile gz_open(path, fd, mode) local gzFile gz_open(const void *path, int fd, const char *mode) {
const void *path;
int fd;
const char *mode;
{
gz_statep state; gz_statep state;
z_size_t len; z_size_t len;
int oflag; int oflag;
@ -270,26 +262,17 @@ local gzFile gz_open(path, fd, mode)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
gzFile ZEXPORT gzopen(path, mode) gzFile ZEXPORT gzopen(const char *path, const char *mode) {
const char *path;
const char *mode;
{
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
gzFile ZEXPORT gzopen64(path, mode) gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
const char *path;
const char *mode;
{
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
gzFile ZEXPORT gzdopen(fd, mode) gzFile ZEXPORT gzdopen(int fd, const char *mode) {
int fd;
const char *mode;
{
char *path; /* identifier for error messages */ char *path; /* identifier for error messages */
gzFile gz; gzFile gz;
@ -307,19 +290,13 @@ gzFile ZEXPORT gzdopen(fd, mode)
/* -- see zlib.h -- */ /* -- see zlib.h -- */
#ifdef WIDECHAR #ifdef WIDECHAR
gzFile ZEXPORT gzopen_w(path, mode) gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
const wchar_t *path;
const char *mode;
{
return gz_open(path, -2, mode); return gz_open(path, -2, mode);
} }
#endif #endif
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzbuffer(file, size) int ZEXPORT gzbuffer(gzFile file, unsigned size) {
gzFile file;
unsigned size;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
@ -343,9 +320,7 @@ int ZEXPORT gzbuffer(file, size)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzrewind(file) int ZEXPORT gzrewind(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
@ -366,11 +341,7 @@ int ZEXPORT gzrewind(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off64_t ZEXPORT gzseek64(file, offset, whence) z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
gzFile file;
z_off64_t offset;
int whence;
{
unsigned n; unsigned n;
z_off64_t ret; z_off64_t ret;
gz_statep state; gz_statep state;
@ -443,11 +414,7 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off_t ZEXPORT gzseek(file, offset, whence) z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
gzFile file;
z_off_t offset;
int whence;
{
z_off64_t ret; z_off64_t ret;
ret = gzseek64(file, (z_off64_t)offset, whence); ret = gzseek64(file, (z_off64_t)offset, whence);
@ -455,9 +422,7 @@ z_off_t ZEXPORT gzseek(file, offset, whence)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off64_t ZEXPORT gztell64(file) z_off64_t ZEXPORT gztell64(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
@ -472,9 +437,7 @@ z_off64_t ZEXPORT gztell64(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off_t ZEXPORT gztell(file) z_off_t ZEXPORT gztell(gzFile file) {
gzFile file;
{
z_off64_t ret; z_off64_t ret;
ret = gztell64(file); ret = gztell64(file);
@ -482,9 +445,7 @@ z_off_t ZEXPORT gztell(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off64_t ZEXPORT gzoffset64(file) z_off64_t ZEXPORT gzoffset64(gzFile file) {
gzFile file;
{
z_off64_t offset; z_off64_t offset;
gz_statep state; gz_statep state;
@ -505,9 +466,7 @@ z_off64_t ZEXPORT gzoffset64(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_off_t ZEXPORT gzoffset(file) z_off_t ZEXPORT gzoffset(gzFile file) {
gzFile file;
{
z_off64_t ret; z_off64_t ret;
ret = gzoffset64(file); ret = gzoffset64(file);
@ -515,9 +474,7 @@ z_off_t ZEXPORT gzoffset(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzeof(file) int ZEXPORT gzeof(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
@ -532,10 +489,7 @@ int ZEXPORT gzeof(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
const char * ZEXPORT gzerror(file, errnum) const char * ZEXPORT gzerror(gzFile file, int *errnum) {
gzFile file;
int *errnum;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
@ -553,9 +507,7 @@ const char * ZEXPORT gzerror(file, errnum)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
void ZEXPORT gzclearerr(file) void ZEXPORT gzclearerr(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure and check integrity */ /* get internal structure and check integrity */
@ -579,11 +531,7 @@ void ZEXPORT gzclearerr(file)
memory). Simply save the error message as a static string. If there is an memory). Simply save the error message as a static string. If there is an
allocation failure constructing the error message, then convert the error to allocation failure constructing the error message, then convert the error to
out of memory. */ out of memory. */
void ZLIB_INTERNAL gz_error(state, err, msg) void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
gz_statep state;
int err;
const char *msg;
{
/* free previously allocated message and clear */ /* free previously allocated message and clear */
if (state.state->msg != NULL) { if (state.state->msg != NULL) {
if (state.state->err != Z_MEM_ERROR) if (state.state->err != Z_MEM_ERROR)
@ -625,8 +573,7 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
available) -- we need to do this to cover cases where 2's complement not available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations, used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */ otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax() unsigned ZLIB_INTERNAL gz_intmax() {
{
unsigned p, q; unsigned p, q;
p = 1; p = 1;

View File

@ -29,12 +29,8 @@ local z_size_t gz_read _Z_OF((gz_statep, voidp, z_size_t));
state.state->fd, and update state.state->eof, state.state->err, and state.state->msg as appropriate. state.state->fd, and update state.state->eof, state.state->err, and state.state->msg as appropriate.
This function needs to loop on read(), since read() is not guaranteed to This function needs to loop on read(), since read() is not guaranteed to
read the number of bytes requested, depending on the type of descriptor. */ read the number of bytes requested, depending on the type of descriptor. */
local int gz_load(state, buf, len, have) local int gz_load(gz_statep state, unsigned char *buf, unsigned len,
gz_statep state; unsigned *have) {
unsigned char *buf;
unsigned len;
unsigned *have;
{
ssize_t ret; ssize_t ret;
unsigned get, max = ((unsigned)-1 >> 2) + 1; unsigned get, max = ((unsigned)-1 >> 2) + 1;
@ -64,8 +60,7 @@ local int gz_load(state, buf, len, have)
If strm->avail_in != 0, then the current data is moved to the beginning of If strm->avail_in != 0, then the current data is moved to the beginning of
the input buffer, and then the remainder of the buffer is loaded with the the input buffer, and then the remainder of the buffer is loaded with the
available data from the input file. */ available data from the input file. */
local int gz_avail(state) local int gz_avail(gz_statep state)
gz_statep state;
{ {
unsigned got; unsigned got;
z_streamp strm = &(state.state->strm); z_streamp strm = &(state.state->strm);
@ -99,9 +94,7 @@ local int gz_avail(state)
case, all further file reads will be directly to either the output buffer or case, all further file reads will be directly to either the output buffer or
a user buffer. If decompressing, the inflate state will be initialized. a user buffer. If decompressing, the inflate state will be initialized.
gz_look() will return 0 on success or -1 on failure. */ gz_look() will return 0 on success or -1 on failure. */
local int gz_look(state) local int gz_look(gz_statep state) {
gz_statep state;
{
z_streamp strm = &(state.state->strm); z_streamp strm = &(state.state->strm);
/* allocate read buffers and inflate memory */ /* allocate read buffers and inflate memory */
@ -184,9 +177,7 @@ local int gz_look(state)
data. If the gzip stream completes, state.state->how is reset to LOOK to look for data. If the gzip stream completes, state.state->how is reset to LOOK to look for
the next gzip stream or raw data, once state.state->x.have is depleted. Returns 0 the next gzip stream or raw data, once state.state->x.have is depleted. Returns 0
on success, -1 on failure. */ on success, -1 on failure. */
local int gz_decomp(state) local int gz_decomp(gz_statep state) {
gz_statep state;
{
int ret = Z_OK; int ret = Z_OK;
unsigned had; unsigned had;
z_streamp strm = &(state.state->strm); z_streamp strm = &(state.state->strm);
@ -238,9 +229,7 @@ local int gz_decomp(state)
looked for to determine whether to copy or decompress. Returns -1 on error, looked for to determine whether to copy or decompress. Returns -1 on error,
otherwise 0. gz_fetch() will leave state.state->how as COPY or GZIP unless the otherwise 0. gz_fetch() will leave state.state->how as COPY or GZIP unless the
end of the input file has been reached and all data has been processed. */ end of the input file has been reached and all data has been processed. */
local int gz_fetch(state) local int gz_fetch(gz_statep state) {
gz_statep state;
{
z_streamp strm = &(state.state->strm); z_streamp strm = &(state.state->strm);
do { do {
@ -268,10 +257,7 @@ local int gz_fetch(state)
} }
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
local int gz_skip(state, len) local int gz_skip(gz_statep state, z_off64_t len) {
gz_statep state;
z_off64_t len;
{
unsigned n; unsigned n;
/* skip over len bytes or reach end-of-file, whichever comes first */ /* skip over len bytes or reach end-of-file, whichever comes first */
@ -303,11 +289,7 @@ local int gz_skip(state, len)
input. Return the number of bytes read. If zero is returned, either the input. Return the number of bytes read. If zero is returned, either the
end of file was reached, or there was an error. state.state->err must be end of file was reached, or there was an error. state.state->err must be
consulted in that case to determine which. */ consulted in that case to determine which. */
local z_size_t gz_read(state, buf, len) local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) {
gz_statep state;
voidp buf;
z_size_t len;
{
z_size_t got; z_size_t got;
unsigned n; unsigned n;
@ -384,11 +366,7 @@ local z_size_t gz_read(state, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzread(file, buf, len) int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) {
gzFile file;
voidp buf;
unsigned len;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
@ -420,12 +398,8 @@ int ZEXPORT gzread(file, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_size_t ZEXPORT gzfread(buf, size, nitems, file) z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems,
voidp buf; gzFile file) {
z_size_t size;
z_size_t nitems;
gzFile file;
{
z_size_t len; z_size_t len;
gz_statep state; gz_statep state;
@ -468,9 +442,7 @@ ZEXTERN int ZEXPORT gzgetc _Z_OF((gzFile file));
ZEXTERN int ZEXPORT gzgetc_ _Z_OF((gzFile file)); ZEXTERN int ZEXPORT gzgetc_ _Z_OF((gzFile file));
#endif #endif
int ZEXPORT gzgetc(file) int ZEXPORT gzgetc(gzFile file) {
gzFile file;
{
int ret; int ret;
unsigned char buf[1]; unsigned char buf[1];
gz_statep state; gz_statep state;
@ -497,17 +469,12 @@ int ZEXPORT gzgetc(file)
return ret < 1 ? -1 : buf[0]; return ret < 1 ? -1 : buf[0];
} }
int ZEXPORT gzgetc_(file) int ZEXPORT gzgetc_(gzFile file) {
gzFile file;
{
return gzgetc(file); return gzgetc(file);
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzungetc(c, file) int ZEXPORT gzungetc(int c, gzFile file) {
int c;
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
@ -564,11 +531,7 @@ int ZEXPORT gzungetc(c, file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
char * ZEXPORT gzgets(file, buf, len) char * ZEXPORT gzgets(gzFile file, char *buf, int len) {
gzFile file;
char *buf;
int len;
{
unsigned left, n; unsigned left, n;
char *str; char *str;
unsigned char *eol; unsigned char *eol;
@ -628,9 +591,7 @@ char * ZEXPORT gzgets(file, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzdirect(file) int ZEXPORT gzdirect(gzFile file) {
gzFile file;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
@ -648,9 +609,7 @@ int ZEXPORT gzdirect(file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzclose_r(file) int ZEXPORT gzclose_r(gzFile file) {
gzFile file;
{
int ret, err; int ret, err;
gz_statep state; gz_statep state;

View File

@ -19,9 +19,7 @@ local z_size_t gz_write _Z_OF((gz_statep, voidpc, z_size_t));
/* Initialize state for writing a gzip file. Mark initialization by setting /* Initialize state for writing a gzip file. Mark initialization by setting
state.state->size to non-zero. Return -1 on a memory allocation failure, or 0 on state.state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
success. */ success. */
local int gz_init(state) local int gz_init(gz_statep state) {
gz_statep state;
{
int ret; int ret;
z_streamp strm = &(state.state->strm); z_streamp strm = &(state.state->strm);
@ -75,10 +73,7 @@ local int gz_init(state)
deflate() flush value. If flush is Z_FINISH, then the deflate() state is deflate() flush value. If flush is Z_FINISH, then the deflate() state is
reset to start a new gzip stream. If gz->direct is true, then simply write reset to start a new gzip stream. If gz->direct is true, then simply write
to the output file without compressing, and ignore flush. */ to the output file without compressing, and ignore flush. */
local int gz_comp(state, flush) local int gz_comp(gz_statep state, int flush) {
gz_statep state;
int flush;
{
int ret, writ; int ret, writ;
unsigned have, put, max = ((unsigned)-1 >> 2) + 1; unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
z_streamp strm = &(state.state->strm); z_streamp strm = &(state.state->strm);
@ -147,10 +142,7 @@ local int gz_comp(state, flush)
/* Compress len zeros to output. Return -1 on a write error or memory /* Compress len zeros to output. Return -1 on a write error or memory
allocation failure by gz_comp(), or 0 on success. */ allocation failure by gz_comp(), or 0 on success. */
local int gz_zero(state, len) local int gz_zero(gz_statep state, z_off64_t len) {
gz_statep state;
z_off64_t len;
{
int first; int first;
unsigned n; unsigned n;
z_streamp strm = &(state.state->strm); z_streamp strm = &(state.state->strm);
@ -180,11 +172,7 @@ local int gz_zero(state, len)
/* Write len bytes from buf to file. Return the number of bytes written. If /* Write len bytes from buf to file. Return the number of bytes written. If
the returned value is less than len, then there was an error. */ the returned value is less than len, then there was an error. */
local z_size_t gz_write(state, buf, len) local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
gz_statep state;
voidpc buf;
z_size_t len;
{
z_size_t put = len; z_size_t put = len;
/* if len is zero, avoid unnecessary operations */ /* if len is zero, avoid unnecessary operations */
@ -248,11 +236,7 @@ local z_size_t gz_write(state, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzwrite(file, buf, len) int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
gzFile file;
voidpc buf;
unsigned len;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
@ -276,12 +260,8 @@ int ZEXPORT gzwrite(file, buf, len)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
voidpc buf; gzFile file) {
z_size_t size;
z_size_t nitems;
gzFile file;
{
z_size_t len; z_size_t len;
gz_statep state; gz_statep state;
@ -307,10 +287,7 @@ z_size_t ZEXPORT gzfwrite(buf, size, nitems, file)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzputc(file, c) int ZEXPORT gzputc(gzFile file, int c) {
gzFile file;
int c;
{
unsigned have; unsigned have;
unsigned char buf[1]; unsigned char buf[1];
gz_statep state; gz_statep state;
@ -355,10 +332,7 @@ int ZEXPORT gzputc(file, c)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzputs(file, str) int ZEXPORT gzputs(gzFile file, const char *str) {
gzFile file;
const char *str;
{
int ret; int ret;
z_size_t len; z_size_t len;
gz_statep state; gz_statep state;
@ -382,8 +356,7 @@ int ZEXPORT gzputs(file, str)
#include <stdarg.h> #include <stdarg.h>
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
{
int len; int len;
unsigned left; unsigned left;
char *next; char *next;
@ -454,8 +427,7 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va)
return len; return len;
} }
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
{
va_list va; va_list va;
int ret; int ret;
@ -468,13 +440,10 @@ int ZEXPORTVA gzprintf(gzFile file, const char *format, ...)
#else /* !STDC && !Z_HAVE_STDARG_H */ #else /* !STDC && !Z_HAVE_STDARG_H */
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) int a4, int a5, int a6, int a7, int a8, int a9, int a10,
gzFile file; int a11, int a12, int a13, int a14, int a15, int a16,
const char *format; int a17, int a18, int a19, int a20) {
int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20;
{
unsigned len, left; unsigned len, left;
char *next; char *next;
gz_statep state; gz_statep state;
@ -556,10 +525,7 @@ int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
#endif #endif
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzflush(file, flush) int ZEXPORT gzflush(gzFile file, int flush) {
gzFile file;
int flush;
{
gz_statep state; gz_statep state;
/* get internal structure */ /* get internal structure */
@ -588,11 +554,7 @@ int ZEXPORT gzflush(file, flush)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzsetparams(file, level, strategy) int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
gzFile file;
int level;
int strategy;
{
gz_statep state; gz_statep state;
z_streamp strm; z_streamp strm;
@ -630,9 +592,7 @@ int ZEXPORT gzsetparams(file, level, strategy)
} }
/* -- see zlib.h -- */ /* -- see zlib.h -- */
int ZEXPORT gzclose_w(file) int ZEXPORT gzclose_w(gzFile file) {
gzFile file;
{
int ret = Z_OK; int ret = Z_OK;
gz_statep state; gz_statep state;