Skip to content

Commit

Permalink
zlibWrapper: Update for zlib 1.2.12 (#3217)
Browse files Browse the repository at this point in the history
In zlib 1.2.12 the OF macro was changed to _Z_OF breaking any
project that used zlibWrapper. To fix this the OF has been
changed to _Z_OF everywhere and _Z_OF is defined as OF in the
case it is not yet defined for zlib 1.2.11 and older.

Fixes: #3216
  • Loading branch information
orbea committed Jul 29, 2022
1 parent b1bbb0e commit 1e09cff
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 115 deletions.
26 changes: 13 additions & 13 deletions zlibWrapper/examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,26 @@ z_const char hello[] = "hello, hello! I said hello, hello!";
const char dictionary[] = "hello, hello!";
uLong dictId; /* Adler32 value of the dictionary */

void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen,
void test_deflate _Z_OF((Byte *compr, uLong comprLen));
void test_inflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_deflate OF((Byte *compr, uLong comprLen,
void test_large_deflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_inflate OF((Byte *compr, uLong comprLen,
void test_large_inflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_flush OF((Byte *compr, uLong *comprLen));
void test_sync OF((Byte *compr, uLong comprLen,
void test_flush _Z_OF((Byte *compr, uLong *comprLen));
void test_sync _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_dict_deflate OF((Byte *compr, uLong comprLen));
void test_dict_inflate OF((Byte *compr, uLong comprLen,
void test_dict_deflate _Z_OF((Byte *compr, uLong comprLen));
void test_dict_inflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
int main OF((int argc, char *argv[]));
int main _Z_OF((int argc, char *argv[]));


#ifdef Z_SOLO

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;
Expand All @@ -102,9 +102,9 @@ static free_func zfree = myfree;
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;

void test_compress OF((Byte *compr, uLong comprLen,
void test_compress _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname,
void test_gzio _Z_OF((const char *fname,
Byte *uncompr, uLong uncomprLen));

/* ===========================================================================
Expand Down
26 changes: 13 additions & 13 deletions zlibWrapper/examples/example_original.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,26 @@ z_const char hello[] = "hello, hello!";
const char dictionary[] = "hello";
uLong dictId; /* Adler32 value of the dictionary */

void test_deflate OF((Byte *compr, uLong comprLen));
void test_inflate OF((Byte *compr, uLong comprLen,
void test_deflate _Z_OF((Byte *compr, uLong comprLen));
void test_inflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_deflate OF((Byte *compr, uLong comprLen,
void test_large_deflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_large_inflate OF((Byte *compr, uLong comprLen,
void test_large_inflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_flush OF((Byte *compr, uLong *comprLen));
void test_sync OF((Byte *compr, uLong comprLen,
void test_flush _Z_OF((Byte *compr, uLong *comprLen));
void test_sync _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_dict_deflate OF((Byte *compr, uLong comprLen));
void test_dict_inflate OF((Byte *compr, uLong comprLen,
void test_dict_deflate _Z_OF((Byte *compr, uLong comprLen));
void test_dict_inflate _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
int main OF((int argc, char *argv[]));
int main _Z_OF((int argc, char *argv[]));


#ifdef Z_SOLO

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;
Expand All @@ -94,9 +94,9 @@ static free_func zfree = myfree;
static alloc_func zalloc = (alloc_func)0;
static free_func zfree = (free_func)0;

void test_compress OF((Byte *compr, uLong comprLen,
void test_compress _Z_OF((Byte *compr, uLong comprLen,
Byte *uncompr, uLong uncomprLen));
void test_gzio OF((const char *fname,
void test_gzio _Z_OF((const char *fname,
Byte *uncompr, uLong uncomprLen));

/* ===========================================================================
Expand Down
34 changes: 17 additions & 17 deletions zlibWrapper/examples/minigzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

#if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE)
#ifndef WIN32 /* unlink already in stdio.h for WIN32 */
extern int unlink OF((const char *));
extern int unlink _Z_OF((const char *));
#endif
#endif

Expand Down Expand Up @@ -154,8 +154,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;
Expand All @@ -180,9 +180,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;
Expand Down Expand Up @@ -236,7 +236,7 @@ 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;
Expand All @@ -260,7 +260,7 @@ 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;
Expand Down Expand Up @@ -297,7 +297,7 @@ int gzread(gz, buf, len)
return len - strm->avail_out;
}

int gzclose OF((gzFile));
int gzclose _Z_OF((gzFile));

int gzclose(gz)
gzFile gz;
Expand Down Expand Up @@ -326,7 +326,7 @@ 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;
Expand All @@ -340,15 +340,15 @@ 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
Expand Down
14 changes: 7 additions & 7 deletions zlibWrapper/gzcompatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@


#if ZLIB_VERNUM <= 0x1240
ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
ZEXTERN int ZEXPORT gzclose_w OF((gzFile file));
ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size));
ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file));
ZEXTERN int ZEXPORT gzclose_r _Z_OF((gzFile file));
ZEXTERN int ZEXPORT gzclose_w _Z_OF((gzFile file));
ZEXTERN int ZEXPORT gzbuffer _Z_OF((gzFile file, unsigned size));
ZEXTERN z_off_t ZEXPORT gzoffset _Z_OF((gzFile file));

#if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t
Expand All @@ -40,7 +40,7 @@ struct gzFile_s {
#if ZLIB_VERNUM <= 0x1270
#if defined(_WIN32) && !defined(Z_SOLO)
# include <stddef.h> /* for wchar_t */
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
ZEXTERN gzFile ZEXPORT gzopen_w _Z_OF((const wchar_t *path,
const char *mode));
#endif
#endif
Expand All @@ -61,8 +61,8 @@ ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
# endif
# undef z_longlong
#endif
ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems,
ZEXTERN z_size_t ZEXPORT gzfread _Z_OF((voidp buf, z_size_t size, z_size_t nitems,
gzFile file));
ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size,
ZEXTERN z_size_t ZEXPORT gzfwrite _Z_OF((voidpc buf, z_size_t size,
z_size_t nitems, gzFile file));
#endif
18 changes: 9 additions & 9 deletions zlibWrapper/gzguts.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@

/* gz* functions always use library allocation functions */
#ifndef STDC
extern voidp malloc OF((uInt size));
extern void free OF((voidpf ptr));
extern voidp malloc _Z_OF((uInt size));
extern void free _Z_OF((voidpf ptr));
#endif

/* get errno and strerror definition */
Expand All @@ -145,10 +145,10 @@

/* provide prototypes for these when building zlib without LFS */
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile));
ZEXTERN gzFile ZEXPORT gzopen64 _Z_OF((const char *, const char *));
ZEXTERN z_off64_t ZEXPORT gzseek64 _Z_OF((gzFile, z_off64_t, int));
ZEXTERN z_off64_t ZEXPORT gztell64 _Z_OF((gzFile));
ZEXTERN z_off64_t ZEXPORT gzoffset64 _Z_OF((gzFile));
#endif

/* default memLevel */
Expand Down Expand Up @@ -213,9 +213,9 @@ typedef union {
} gz_statep;

/* shared functions */
void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *));
void ZLIB_INTERNAL gz_error _Z_OF((gz_statep, int, const char *));
#if defined UNDER_CE
char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
char ZLIB_INTERNAL *gz_strwinerror _Z_OF((DWORD error));
#endif

/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
Expand All @@ -224,6 +224,6 @@ char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error));
#ifdef INT_MAX
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
#else
unsigned ZLIB_INTERNAL gz_intmax OF((void));
unsigned ZLIB_INTERNAL gz_intmax _Z_OF((void));
# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
#endif
4 changes: 2 additions & 2 deletions zlibWrapper/gzlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#endif

/* Local functions */
local void gz_reset OF((gz_statep));
local gzFile gz_open OF((const void *, int, const char *));
local void gz_reset _Z_OF((gz_statep));
local gzFile gz_open _Z_OF((const void *, int, const char *));

#if defined UNDER_CE

Expand Down
18 changes: 9 additions & 9 deletions zlibWrapper/gzread.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@


/* Local functions */
local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *));
local int gz_avail OF((gz_statep));
local int gz_look OF((gz_statep));
local int gz_decomp OF((gz_statep));
local int gz_fetch OF((gz_statep));
local int gz_skip OF((gz_statep, z_off64_t));
local z_size_t gz_read OF((gz_statep, voidp, z_size_t));
local int gz_load _Z_OF((gz_statep, unsigned char *, unsigned, unsigned *));
local int gz_avail _Z_OF((gz_statep));
local int gz_look _Z_OF((gz_statep));
local int gz_decomp _Z_OF((gz_statep));
local int gz_fetch _Z_OF((gz_statep));
local int gz_skip _Z_OF((gz_statep, z_off64_t));
local z_size_t gz_read _Z_OF((gz_statep, voidp, z_size_t));

/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
state.state->fd, and update state.state->eof, state.state->err, and state.state->msg as appropriate.
Expand Down Expand Up @@ -464,8 +464,8 @@ z_size_t ZEXPORT gzfread(buf, size, nitems, file)
#endif

#if ZLIB_VERNUM <= 0x1250
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file));
ZEXTERN int ZEXPORT gzgetc _Z_OF((gzFile file));
ZEXTERN int ZEXPORT gzgetc_ _Z_OF((gzFile file));
#endif

int ZEXPORT gzgetc(file)
Expand Down
8 changes: 4 additions & 4 deletions zlibWrapper/gzwrite.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include "gzguts.h"

/* Local functions */
local int gz_init OF((gz_statep));
local int gz_comp OF((gz_statep, int));
local int gz_zero OF((gz_statep, z_off64_t));
local z_size_t gz_write OF((gz_statep, voidpc, z_size_t));
local int gz_init _Z_OF((gz_statep));
local int gz_comp _Z_OF((gz_statep, int));
local int gz_zero _Z_OF((gz_statep, z_off64_t));
local z_size_t gz_write _Z_OF((gz_statep, voidpc, z_size_t));

/* Initialize state for writing a gzip file. Mark initialization by setting
state.state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
Expand Down

0 comments on commit 1e09cff

Please sign in to comment.