diff options
Diffstat (limited to '')
| -rw-r--r-- | minigzip.c | 19 |
1 files changed, 12 insertions, 7 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* minigzip.c -- simulate gzip using the zlib compression library | 1 | /* minigzip.c -- simulate gzip using the zlib compression library |
| 2 | * Copyright (C) 1995 Jean-loup Gailly. | 2 | * Copyright (C) 1995-1996 Jean-loup Gailly. |
| 3 | * For conditions of distribution and use, see copyright notice in zlib.h | 3 | * For conditions of distribution and use, see copyright notice in zlib.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| @@ -13,7 +13,7 @@ | |||
| 13 | * or in pipe mode. | 13 | * or in pipe mode. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | /* $Id: minigzip.c,v 1.5 1995/05/03 17:27:11 jloup Exp $ */ | 16 | /* $Id: minigzip.c,v 1.8 1996/01/30 21:59:23 me Exp $ */ |
| 17 | 17 | ||
| 18 | #include <stdio.h> | 18 | #include <stdio.h> |
| 19 | #include "zlib.h" | 19 | #include "zlib.h" |
| @@ -24,7 +24,7 @@ | |||
| 24 | #else | 24 | #else |
| 25 | extern void exit OF((int)); | 25 | extern void exit OF((int)); |
| 26 | #endif | 26 | #endif |
| 27 | extern int unlink OF((const char *)); | 27 | |
| 28 | 28 | ||
| 29 | #if defined(MSDOS) || defined(OS2) || defined(WIN32) | 29 | #if defined(MSDOS) || defined(OS2) || defined(WIN32) |
| 30 | # include <fcntl.h> | 30 | # include <fcntl.h> |
| @@ -35,12 +35,15 @@ extern int unlink OF((const char *)); | |||
| 35 | #endif | 35 | #endif |
| 36 | 36 | ||
| 37 | #ifdef VMS | 37 | #ifdef VMS |
| 38 | # define unlink delete | ||
| 38 | # define GZ_SUFFIX "-gz" | 39 | # define GZ_SUFFIX "-gz" |
| 39 | #else | 40 | #else |
| 40 | # define GZ_SUFFIX ".gz" | 41 | # define GZ_SUFFIX ".gz" |
| 41 | #endif | 42 | #endif |
| 42 | #define SUFFIX_LEN sizeof(GZ_SUFFIX) | 43 | #define SUFFIX_LEN sizeof(GZ_SUFFIX) |
| 43 | 44 | ||
| 45 | extern int unlink OF((const char *)); | ||
| 46 | |||
| 44 | #define BUFLEN 4096 | 47 | #define BUFLEN 4096 |
| 45 | #define MAX_NAME_LEN 1024 | 48 | #define MAX_NAME_LEN 1024 |
| 46 | 49 | ||
| @@ -52,7 +55,7 @@ extern int unlink OF((const char *)); | |||
| 52 | 55 | ||
| 53 | char *prog; | 56 | char *prog; |
| 54 | 57 | ||
| 55 | void error OF((char *msg)); | 58 | void error OF((const char *msg)); |
| 56 | void gz_compress OF((FILE *in, gzFile out)); | 59 | void gz_compress OF((FILE *in, gzFile out)); |
| 57 | void gz_uncompress OF((gzFile in, FILE *out)); | 60 | void gz_uncompress OF((gzFile in, FILE *out)); |
| 58 | void file_compress OF((char *file)); | 61 | void file_compress OF((char *file)); |
| @@ -63,7 +66,7 @@ int main OF((int argc, char *argv[])); | |||
| 63 | * Display error message and exit | 66 | * Display error message and exit |
| 64 | */ | 67 | */ |
| 65 | void error(msg) | 68 | void error(msg) |
| 66 | char *msg; | 69 | const char *msg; |
| 67 | { | 70 | { |
| 68 | fprintf(stderr, "%s: %s\n", prog, msg); | 71 | fprintf(stderr, "%s: %s\n", prog, msg); |
| 69 | exit(1); | 72 | exit(1); |
| @@ -88,7 +91,7 @@ void gz_compress(in, out) | |||
| 88 | } | 91 | } |
| 89 | if (len == 0) break; | 92 | if (len == 0) break; |
| 90 | 93 | ||
| 91 | if (gzwrite(out, buf, len) != len) error(gzerror(out, &err)); | 94 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); |
| 92 | } | 95 | } |
| 93 | fclose(in); | 96 | fclose(in); |
| 94 | if (gzclose(out) != Z_OK) error("failed gzclose"); | 97 | if (gzclose(out) != Z_OK) error("failed gzclose"); |
| @@ -110,7 +113,9 @@ void gz_uncompress(in, out) | |||
| 110 | if (len < 0) error (gzerror(in, &err)); | 113 | if (len < 0) error (gzerror(in, &err)); |
| 111 | if (len == 0) break; | 114 | if (len == 0) break; |
| 112 | 115 | ||
| 113 | if (fwrite(buf, 1, len, out) != (uInt)len) error("failed fwrite"); | 116 | if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { |
| 117 | error("failed fwrite"); | ||
| 118 | } | ||
| 114 | } | 119 | } |
| 115 | if (fclose(out)) error("failed fclose"); | 120 | if (fclose(out)) error("failed fclose"); |
| 116 | 121 | ||
