summaryrefslogtreecommitdiff
path: root/zlibWrapper/examples/minigzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'zlibWrapper/examples/minigzip.c')
-rw-r--r--zlibWrapper/examples/minigzip.c107
1 files changed, 36 insertions, 71 deletions
diff --git a/zlibWrapper/examples/minigzip.c b/zlibWrapper/examples/minigzip.c
index f67be09564f2..ef48d74d2906 100644
--- a/zlibWrapper/examples/minigzip.c
+++ b/zlibWrapper/examples/minigzip.c
@@ -3,7 +3,7 @@
/* minigzip.c -- simulate gzip using the zlib compression library
* Copyright (C) 1995-2006, 2010, 2011 Jean-loup Gailly.
- * For conditions of distribution and use, see http://www.zlib.net/zlib_license.html
+ * For conditions of distribution and use, see https://www.zlib.net/zlib_license.html
*/
/*
@@ -34,7 +34,7 @@
# include <sys/stat.h>
#endif
-#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__)
+#if defined(MSDOS) || defined(OS2) || defined(_WIN32) || defined(__CYGWIN__)
# include <fcntl.h>
# include <io.h>
# ifdef UNDER_CE
@@ -63,8 +63,8 @@
#endif
#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
-#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
- extern int unlink OF((const char *));
+#ifndef _WIN32 /* unlink already in stdio.h for WIN32 */
+ extern int unlink _Z_OF((const char *));
#endif
#endif
@@ -82,8 +82,7 @@
The strwinerror function does not change the current setting
of GetLastError. */
-static char *strwinerror (error)
- DWORD error;
+static char *strwinerror(DWORD error)
{
static char buf[1024];
@@ -121,8 +120,7 @@ static char *strwinerror (error)
return buf;
}
-static void pwinerror (s)
- const char *s;
+static void pwinerror (const char *s)
{
if (s && *s)
fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ()));
@@ -154,8 +152,8 @@ static void pwinerror (s)
# include <unistd.h> /* for unlink() */
#endif
-void *myalloc OF((void *, unsigned, unsigned));
-void myfree OF((void *, void *));
+void *myalloc _Z_OF((void *, unsigned, unsigned));
+void myfree _Z_OF((void *, void *));
void *myalloc(q, n, m)
void *q;
@@ -180,9 +178,9 @@ typedef struct gzFile_s {
z_stream strm;
} *gzFile;
-gzFile gzopen OF((const char *, const char *));
-gzFile gzdopen OF((int, const char *));
-gzFile gz_open OF((const char *, int, const char *));
+gzFile gzopen _Z_OF((const char *, const char *));
+gzFile gzdopen _Z_OF((int, const char *));
+gzFile gz_open _Z_OF((const char *, int, const char *));
gzFile gzopen(path, mode)
const char *path;
@@ -198,11 +196,7 @@ const char *mode;
return gz_open(NULL, fd, mode);
}
-gzFile gz_open(path, fd, mode)
- const char *path;
- int fd;
- const char *mode;
-{
+gzFile gz_open(const char *path, int fd, const char *mode) {
gzFile gz;
int ret;
@@ -236,15 +230,11 @@ gzFile gz_open(path, fd, mode)
return gz;
}
-int gzwrite OF((gzFile, const void *, unsigned));
+int gzwrite _Z_OF((gzFile, const void *, unsigned));
-int gzwrite(gz, buf, len)
- gzFile gz;
- const void *buf;
- unsigned len;
-{
+int gzwrite(gzFile gz, const void *buf, unsigned len) {
z_stream *strm;
- unsigned char out[BUFLEN];
+ unsigned char out[BUFLEN] = { 0 };
if (gz == NULL || !gz->write)
return 0;
@@ -260,13 +250,9 @@ int gzwrite(gz, buf, len)
return len;
}
-int gzread OF((gzFile, void *, unsigned));
+int gzread _Z_OF((gzFile, void *, unsigned));
-int gzread(gz, buf, len)
- gzFile gz;
- void *buf;
- unsigned len;
-{
+int gzread(gzFile gz, void *buf, unsigned len) {
int ret;
unsigned got;
unsigned char in[1];
@@ -297,13 +283,11 @@ int gzread(gz, buf, len)
return len - strm->avail_out;
}
-int gzclose OF((gzFile));
+int gzclose _Z_OF((gzFile));
-int gzclose(gz)
- gzFile gz;
-{
+int gzclose(gzFile gz) {
z_stream *strm;
- unsigned char out[BUFLEN];
+ unsigned char out[BUFLEN] = { 0 };
if (gz == NULL)
return Z_STREAM_ERROR;
@@ -326,11 +310,9 @@ int gzclose(gz)
return Z_OK;
}
-const char *gzerror OF((gzFile, int *));
+const char *gzerror _Z_OF((gzFile, int *));
-const char *gzerror(gz, err)
- gzFile gz;
- int *err;
+const char *gzerror(gzFile gz, int *err)
{
*err = gz->err;
return gz->msg;
@@ -340,21 +322,20 @@ const char *gzerror(gz, err)
char *prog;
-void error OF((const char *msg));
-void gz_compress OF((FILE *in, gzFile out));
+void error _Z_OF((const char *msg));
+void gz_compress _Z_OF((FILE *in, gzFile out));
#ifdef USE_MMAP
-int gz_compress_mmap OF((FILE *in, gzFile out));
+int gz_compress_mmap _Z_OF((FILE *in, gzFile out));
#endif
-void gz_uncompress OF((gzFile in, FILE *out));
-void file_compress OF((char *file, char *mode));
-void file_uncompress OF((char *file));
-int main OF((int argc, char *argv[]));
+void gz_uncompress _Z_OF((gzFile in, FILE *out));
+void file_compress _Z_OF((char *file, char *mode));
+void file_uncompress _Z_OF((char *file));
+int main _Z_OF((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);
@@ -364,9 +345,7 @@ void error(msg)
* Compress input to output then close both files.
*/
-void gz_compress(in, out)
- FILE *in;
- gzFile out;
+void gz_compress(FILE *in, gzFile out)
{
local char buf[BUFLEN];
int len;
@@ -397,10 +376,7 @@ void gz_compress(in, out)
/* Try compressing the input file at once using mmap. Return Z_OK if
* if success, Z_ERRNO otherwise.
*/
-int gz_compress_mmap(in, out)
- FILE *in;
- gzFile out;
-{
+int gz_compress_mmap(FILE *in, gzFile out) {
int len;
int err;
int ifd = fileno(in);
@@ -432,10 +408,7 @@ int gz_compress_mmap(in, out)
/* ===========================================================================
* Uncompress input to output then close both files.
*/
-void gz_uncompress(in, out)
- gzFile in;
- FILE *out;
-{
+void gz_uncompress(gzFile in, FILE *out) {
local char buf[BUFLEN];
int len;
int err;
@@ -459,10 +432,7 @@ void gz_uncompress(in, out)
* Compress the given file: create a corresponding .gz file and remove the
* original.
*/
-void file_compress(file, mode)
- char *file;
- char *mode;
-{
+void file_compress(char *file, char *mode) {
local char outfile[MAX_NAME_LEN];
FILE *in;
gzFile out;
@@ -494,9 +464,7 @@ void file_compress(file, mode)
/* ===========================================================================
* Uncompress the given file and remove the original.
*/
-void file_uncompress(file)
- char *file;
-{
+void file_uncompress(char *file) {
local char buf[MAX_NAME_LEN];
char *infile, *outfile;
FILE *out;
@@ -546,10 +514,7 @@ void file_uncompress(file)
* -1 to -9 : compression level
*/
-int main(argc, argv)
- int argc;
- char *argv[];
-{
+int main(int argc, char *argv[]) {
int copyout = 0;
int uncompr = 0;
gzFile file;