zlib 0.99

This commit is contained in:
Mark Adler
2011-09-09 23:11:37 -07:00
parent 25e5325501
commit 56bcb184fa
33 changed files with 1833 additions and 775 deletions

View File

@@ -1,5 +1,5 @@
/* minigzip.c -- simulate gzip using the zlib compression library
* Copyright (C) 1995 Jean-loup Gailly.
* Copyright (C) 1995-1996 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -18,14 +18,13 @@
#include <stdio.h>
#include "zlib.h"
#ifndef __GO32__
extern void exit OF((int));
#endif
extern int unlink OF((const char *));
#ifdef STDC
# include <string.h>
# include <stdlib.h>
#else
extern void exit OF((int));
#endif
extern int unlink OF((const char *));
#if defined(MSDOS) || defined(OS2) || defined(WIN32)
# include <fcntl.h>
@@ -53,7 +52,7 @@ extern int unlink OF((const char *));
char *prog;
void error OF((char *msg));
void error OF((const char *msg));
void gz_compress OF((FILE *in, gzFile out));
void gz_uncompress OF((gzFile in, FILE *out));
void file_compress OF((char *file));
@@ -64,7 +63,7 @@ int main OF((int argc, char *argv[]));
* Display error message and exit
*/
void error(msg)
char *msg;
const char *msg;
{
fprintf(stderr, "%s: %s\n", prog, msg);
exit(1);
@@ -89,7 +88,7 @@ void gz_compress(in, out)
}
if (len == 0) break;
if (gzwrite(out, buf, len) != len) error(gzerror(out, &err));
if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err));
}
fclose(in);
if (gzclose(out) != Z_OK) error("failed gzclose");
@@ -111,7 +110,9 @@ void gz_uncompress(in, out)
if (len < 0) error (gzerror(in, &err));
if (len == 0) break;
if (fwrite(buf, 1, len, out) != (uInt)len) error("failed fwrite");
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
error("failed fwrite");
}
}
if (fclose(out)) error("failed fclose");