- WARNSfy
- KNF, ANSIfy, remove __P(), misc cosmetics
This commit is contained in:
parent
a628ef7c5c
commit
aabb34a38b
8
common/dist/zlib/gzio.c
vendored
8
common/dist/zlib/gzio.c
vendored
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gzio.c,v 1.2 2006/01/27 00:45:27 christos Exp $ */
|
||||
/* $NetBSD: gzio.c,v 1.3 2011/05/19 22:23:12 tsutsui Exp $ */
|
||||
|
||||
/* gzio.c -- IO on .gz files
|
||||
* Copyright (C) 1995-2005 Jean-loup Gailly.
|
||||
@ -76,11 +76,15 @@ typedef struct gz_stream {
|
||||
|
||||
|
||||
local gzFile gz_open OF((const char *path, const char *mode, int fd));
|
||||
#ifndef NO_GZCOMPRESS
|
||||
local int do_flush OF((gzFile file, int flush));
|
||||
#endif
|
||||
local int get_byte OF((gz_stream *s));
|
||||
local void check_header OF((gz_stream *s));
|
||||
local int destroy OF((gz_stream *s));
|
||||
#ifndef NO_GZCOMPRESS
|
||||
local void putLong OF((FILE *file, uLong x));
|
||||
#endif
|
||||
local uLong getLong OF((gz_stream *s));
|
||||
|
||||
/* ===========================================================================
|
||||
@ -917,6 +921,7 @@ int ZEXPORT gzdirect (file)
|
||||
return s->transparent;
|
||||
}
|
||||
|
||||
#ifndef NO_GZCOMPRESS
|
||||
/* ===========================================================================
|
||||
Outputs a long in LSB order to the given file
|
||||
*/
|
||||
@ -930,6 +935,7 @@ local void putLong (file, x)
|
||||
x >>= 8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
Reads a long in LSB order from the given gz_stream. Sets z_err in case
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.14 2006/01/14 21:15:40 christos Exp $
|
||||
# $NetBSD: Makefile,v 1.15 2011/05/19 22:23:12 tsutsui Exp $
|
||||
# Small zcat (i.e. for install media)
|
||||
#
|
||||
# Note: gzio.c is compiled here so that crunchgen will assume
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
SRCDIR= ${.CURDIR}/../../../common/dist/zlib
|
||||
|
||||
WARNS?= 4
|
||||
PROG= zcat
|
||||
NOMAN= # defined
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: zcat.c,v 1.3 1998/11/12 16:49:47 thorpej Exp $ */
|
||||
/* $NetBSD: zcat.c,v 1.4 2011/05/19 22:23:12 tsutsui Exp $ */
|
||||
|
||||
/* mini zcat.c -- a minimal zcat using the zlib compression library
|
||||
* Copyright (C) 1995-1996 Jean-loup Gailly.
|
||||
@ -22,43 +22,45 @@
|
||||
|
||||
char *prog;
|
||||
|
||||
void error __P((const char *msg));
|
||||
void gz_uncompress __P((gzFile in, FILE *out));
|
||||
int main __P((int argc, char *argv[]));
|
||||
void error(const char *msg);
|
||||
void gz_uncompress(gzFile in, FILE *out);
|
||||
int main(int argc, char *argv[]);
|
||||
|
||||
/* ===========================================================================
|
||||
* Display error message and exit
|
||||
*/
|
||||
void error(msg)
|
||||
const char *msg;
|
||||
void error(const char *msg)
|
||||
{
|
||||
fprintf(stderr, "%s: %s\n", prog, msg);
|
||||
exit(1);
|
||||
|
||||
fprintf(stderr, "%s: %s\n", prog, msg);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Uncompress input to output then close both files.
|
||||
*/
|
||||
void gz_uncompress(in, out)
|
||||
gzFile in;
|
||||
FILE *out;
|
||||
void gz_uncompress(gzFile in, FILE *out)
|
||||
{
|
||||
char buf[BUFLEN];
|
||||
int len;
|
||||
int err;
|
||||
char buf[BUFLEN];
|
||||
int len;
|
||||
int err;
|
||||
|
||||
for (;;) {
|
||||
len = gzread(in, buf, sizeof(buf));
|
||||
if (len < 0) error (gzerror(in, &err));
|
||||
if (len == 0) break;
|
||||
for (;;) {
|
||||
len = gzread(in, buf, sizeof(buf));
|
||||
if (len < 0)
|
||||
error (gzerror(in, &err));
|
||||
if (len == 0)
|
||||
break;
|
||||
|
||||
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
|
||||
error("failed fwrite");
|
||||
if ((int)fwrite(buf, 1, (unsigned)len, out) != len) {
|
||||
error("failed fwrite");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fclose(out)) error("failed fclose");
|
||||
if (fclose(out))
|
||||
error("failed fclose");
|
||||
|
||||
if (gzclose(in) != Z_OK) error("failed gzclose");
|
||||
if (gzclose(in) != Z_OK)
|
||||
error("failed gzclose");
|
||||
}
|
||||
|
||||
|
||||
@ -66,39 +68,37 @@ void gz_uncompress(in, out)
|
||||
* Usage: zcat [files...]
|
||||
*/
|
||||
|
||||
int main(argc, argv)
|
||||
int argc;
|
||||
char *argv[];
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
gzFile zfp;
|
||||
gzFile zfp;
|
||||
|
||||
/* save program name and skip */
|
||||
prog = argv[0];
|
||||
argc--, argv++;
|
||||
prog = argv[0];
|
||||
argc--, argv++;
|
||||
|
||||
/* ignore any switches */
|
||||
while (*argv && (**argv == '-')) {
|
||||
argc--, argv++;
|
||||
}
|
||||
argc--, argv++;
|
||||
}
|
||||
|
||||
if (argc == 0) {
|
||||
if (argc == 0) {
|
||||
zfp = gzdopen(fileno(stdin), "rb");
|
||||
if (zfp == NULL)
|
||||
error("can't gzdopen stdin");
|
||||
gz_uncompress(zfp, stdout);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
/* file_uncompress(*argv); */
|
||||
zfp = gzopen(*argv, "rb");
|
||||
if (zfp == NULL) {
|
||||
fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv);
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
gz_uncompress(zfp, stdout);
|
||||
} while (argv++, --argc);
|
||||
return 0; /* to avoid warning */
|
||||
return 0; /* to avoid warning */
|
||||
}
|
||||
|
||||
|
||||
@ -106,24 +106,28 @@ int main(argc, argv)
|
||||
* XXX: hacks to keep gzio.c from pulling in deflate stuff
|
||||
*/
|
||||
|
||||
int deflateInit2_ (z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy,
|
||||
const char *version, int stream_size)
|
||||
int deflateInit2_(z_streamp strm, int level, int method,
|
||||
int windowBits, int memLevel, int strategy,
|
||||
const char *version, int stream_size)
|
||||
{
|
||||
return(-1);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int deflate (z_streamp strm, int flush)
|
||||
int deflate(z_streamp strm, int flush)
|
||||
{
|
||||
return(-1);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int deflateEnd (z_streamp strm)
|
||||
int deflateEnd(z_streamp strm)
|
||||
{
|
||||
return(-1);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int deflateParams (z_streamp strm, int level, int strategy)
|
||||
int deflateParams(z_streamp strm, int level, int strategy)
|
||||
{
|
||||
return(Z_STREAM_ERROR);
|
||||
|
||||
return Z_STREAM_ERROR;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user