minigzip.c (muscle7.61) | : | minigzip.c (muscle7.62) | ||
---|---|---|---|---|
/* minigzip.c -- simulate gzip using the zlib compression library | /* minigzip.c -- simulate gzip using the zlib compression library | |||
* Copyright (C) 1995-2006, 2010, 2011 Jean-loup Gailly. | * Copyright (C) 1995-2006, 2010, 2011, 2016 Jean-loup Gailly | |||
* For conditions of distribution and use, see copyright notice in zlib.h | * For conditions of distribution and use, see copyright notice in zlib.h | |||
*/ | */ | |||
/* | /* | |||
* minigzip is a minimal implementation of the gzip utility. This is | * minigzip is a minimal implementation of the gzip utility. This is | |||
* only an example of using zlib and isn't meant to replace the | * only an example of using zlib and isn't meant to replace the | |||
* full-featured gzip. No attempt is made to deal with file systems | * full-featured gzip. No attempt is made to deal with file systems | |||
* limiting names to 14 or 8+3 characters, etc... Error checking is | * limiting names to 14 or 8+3 characters, etc... Error checking is | |||
* very limited. So use minigzip only for testing; use gzip for the | * very limited. So use minigzip only for testing; use gzip for the | |||
* real thing. On MSDOS, use only on file names without extension | * real thing. On MSDOS, use only on file names without extension | |||
skipping to change at line 43 | skipping to change at line 43 | |||
# include <fcntl.h> | # include <fcntl.h> | |||
# include <io.h> | # include <io.h> | |||
# ifdef UNDER_CE | # ifdef UNDER_CE | |||
# include <stdlib.h> | # include <stdlib.h> | |||
# endif | # endif | |||
# define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) | # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) | |||
#else | #else | |||
# define SET_BINARY_MODE(file) | # define SET_BINARY_MODE(file) | |||
#endif | #endif | |||
#ifdef _MSC_VER | #if defined(_MSC_VER) && _MSC_VER < 1900 | |||
# define snprintf _snprintf | # define snprintf _snprintf | |||
#endif | #endif | |||
#ifdef VMS | #ifdef VMS | |||
# define unlink delete | # define unlink delete | |||
# define GZ_SUFFIX "-gz" | # define GZ_SUFFIX "-gz" | |||
#endif | #endif | |||
#ifdef RISCOS | #ifdef RISCOS | |||
# define unlink remove | # define unlink remove | |||
# define GZ_SUFFIX "-gz" | # define GZ_SUFFIX "-gz" | |||
skipping to change at line 159 | skipping to change at line 159 | |||
# include <unistd.h> /* for unlink() */ | # include <unistd.h> /* for unlink() */ | |||
#endif | #endif | |||
void *myalloc OF((void *, unsigned, unsigned)); | void *myalloc OF((void *, unsigned, unsigned)); | |||
void myfree OF((void *, void *)); | void myfree OF((void *, void *)); | |||
void *myalloc(q, n, m) | void *myalloc(q, n, m) | |||
void *q; | void *q; | |||
unsigned n, m; | unsigned n, m; | |||
{ | { | |||
q = Z_NULL; | (void)q; | |||
return calloc(n, m); | return calloc(n, m); | |||
} | } | |||
void myfree(q, p) | void myfree(q, p) | |||
void *q, *p; | void *q, *p; | |||
{ | { | |||
q = Z_NULL; | (void)q; | |||
free(p); | free(p); | |||
} | } | |||
typedef struct gzFile_s { | typedef struct gzFile_s { | |||
FILE *file; | FILE *file; | |||
int write; | int write; | |||
int err; | int err; | |||
char *msg; | char *msg; | |||
z_stream strm; | z_stream strm; | |||
} *gzFile; | } *gzFile; | |||
skipping to change at line 336 | skipping to change at line 336 | |||
const char *gzerror(gz, err) | const char *gzerror(gz, err) | |||
gzFile gz; | gzFile gz; | |||
int *err; | int *err; | |||
{ | { | |||
*err = gz->err; | *err = gz->err; | |||
return gz->msg; | return gz->msg; | |||
} | } | |||
#endif | #endif | |||
char *prog; | static char *prog; | |||
void error OF((const char *msg)); | void error OF((const char *msg)); | |||
void gz_compress OF((FILE *in, gzFile out)); | void gz_compress OF((FILE *in, gzFile out)); | |||
#ifdef USE_MMAP | #ifdef USE_MMAP | |||
int gz_compress_mmap OF((FILE *in, gzFile out)); | int gz_compress_mmap OF((FILE *in, gzFile out)); | |||
#endif | #endif | |||
void gz_uncompress OF((gzFile in, FILE *out)); | void gz_uncompress OF((gzFile in, FILE *out)); | |||
void file_compress OF((char *file, char *mode)); | void file_compress OF((char *file, char *mode)); | |||
void file_uncompress OF((char *file)); | void file_uncompress OF((char *file)); | |||
int main OF((int argc, char *argv[])); | int main OF((int argc, char *argv[])); | |||
skipping to change at line 501 | skipping to change at line 501 | |||
/* =========================================================================== | /* =========================================================================== | |||
* Uncompress the given file and remove the original. | * Uncompress the given file and remove the original. | |||
*/ | */ | |||
void file_uncompress(file) | void file_uncompress(file) | |||
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; | |||
gzFile in; | gzFile in; | |||
size_t len = strlen(file); | unsigned len = strlen(file); | |||
if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { | if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { | |||
fprintf(stderr, "%s: filename too long\n", prog); | fprintf(stderr, "%s: filename too long\n", prog); | |||
exit(1); | exit(1); | |||
} | } | |||
#if !defined(NO_snprintf) && !defined(NO_vsnprintf) | #if !defined(NO_snprintf) && !defined(NO_vsnprintf) | |||
snprintf(buf, sizeof(buf), "%s", file); | snprintf(buf, sizeof(buf), "%s", file); | |||
#else | #else | |||
strcpy(buf, file); | strcpy(buf, file); | |||
End of changes. 6 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added |