From bdde4e09d21edff02ea5093b7f6eccbf166b272f Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Fri, 9 Sep 2011 23:08:07 -0700 Subject: zlib 0.92 --- minigzip.c | 90 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) (limited to 'minigzip.c') diff --git a/minigzip.c b/minigzip.c index 8f58080..017c3e4 100644 --- a/minigzip.c +++ b/minigzip.c @@ -13,7 +13,7 @@ * or in pipe mode. */ -/* $Id: minigzip.c,v 1.4 1995/05/02 15:54:22 jloup Exp $ */ +/* $Id: minigzip.c,v 1.5 1995/05/03 17:27:11 jloup Exp $ */ #include #include "zlib.h" @@ -75,14 +75,14 @@ void gz_compress(in, out) int err; for (;;) { - len = fread(buf, 1, sizeof(buf), in); - if (ferror(in)) { - perror("fread"); - exit(1); - } - if (len == 0) break; - - if (gzwrite(out, buf, len) != len) error(gzerror(out, &err)); + len = fread(buf, 1, sizeof(buf), in); + if (ferror(in)) { + perror("fread"); + exit(1); + } + if (len == 0) break; + + if (gzwrite(out, buf, len) != len) error(gzerror(out, &err)); } fclose(in); if (gzclose(out) != Z_OK) error("failed gzclose"); @@ -100,11 +100,11 @@ void gz_uncompress(in, out) int err; for (;;) { - len = gzread(in, buf, sizeof(buf)); - if (len < 0) error (gzerror(in, &err)); - if (len == 0) break; + len = gzread(in, buf, sizeof(buf)); + if (len < 0) error (gzerror(in, &err)); + if (len == 0) break; - if (fwrite(buf, 1, len, out) != (uInt)len) error("failed fwrite"); + if (fwrite(buf, 1, len, out) != (uInt)len) error("failed fwrite"); } if (fclose(out)) error("failed fclose"); @@ -128,13 +128,13 @@ void file_compress(file) in = fopen(file, "rb"); if (in == NULL) { - perror(file); - exit(1); + perror(file); + exit(1); } out = gzopen(outfile, "wb"); if (out == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); - exit(1); + fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); + exit(1); } gz_compress(in, out); @@ -157,23 +157,23 @@ void file_uncompress(file) strcpy(buf, file); if (len > 3 && strcmp(file+len-3, ".gz") == 0) { - infile = file; - outfile = buf; - outfile[len-3] = '\0'; + infile = file; + outfile = buf; + outfile[len-3] = '\0'; } else { - outfile = file; - infile = buf; - strcat(infile, ".gz"); + outfile = file; + infile = buf; + strcat(infile, ".gz"); } in = gzopen(infile, "rb"); if (in == NULL) { - fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); - exit(1); + fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); + exit(1); } out = fopen(outfile, "wb"); if (out == NULL) { - perror(file); - exit(1); + perror(file); + exit(1); } gz_uncompress(in, out); @@ -197,31 +197,31 @@ void main(argc, argv) argc--, argv++; if (argc > 0) { - uncompr = (strcmp(*argv, "-d") == 0); - if (uncompr) { - argc--, argv++; - } + uncompr = (strcmp(*argv, "-d") == 0); + if (uncompr) { + argc--, argv++; + } } if (argc == 0) { SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); - if (uncompr) { - file = gzdopen(fileno(stdin), "rb"); + if (uncompr) { + file = gzdopen(fileno(stdin), "rb"); if (file == NULL) error("can't gzdopen stdin"); - gz_uncompress(file, stdout); - } else { - file = gzdopen(fileno(stdout), "wb"); + gz_uncompress(file, stdout); + } else { + file = gzdopen(fileno(stdout), "wb"); if (file == NULL) error("can't gzdopen stdout"); - gz_compress(stdin, file); - } + gz_compress(stdin, file); + } } else { - do { - if (uncompr) { - file_uncompress(*argv); - } else { - file_compress(*argv); - } - } while (argv++, --argc); + do { + if (uncompr) { + file_uncompress(*argv); + } else { + file_compress(*argv); + } + } while (argv++, --argc); } exit(0); } -- cgit v1.2.3-55-g6feb