|
| 1 | +#ifndef COMPAT_ZLIB_H |
| 2 | +#define COMPAT_ZLIB_H |
| 3 | + |
| 4 | +#ifdef HAVE_ZLIB_NG |
| 5 | +# include <zlib-ng.h> |
| 6 | + |
| 7 | +# define z_stream zng_stream |
| 8 | +#define gz_header_s zng_gz_header_s |
| 9 | + |
| 10 | +# define crc32(crc, buf, len) zng_crc32(crc, buf, len) |
| 11 | + |
| 12 | +# define inflate(strm, bits) zng_inflate(strm, bits) |
| 13 | +# define inflateEnd(strm) zng_inflateEnd(strm) |
| 14 | +# define inflateInit(strm) zng_inflateInit(strm) |
| 15 | +# define inflateInit2(strm, bits) zng_inflateInit2(strm, bits) |
| 16 | +# define inflateReset(strm) zng_inflateReset(strm) |
| 17 | + |
| 18 | +# define deflate(strm, flush) zng_deflate(strm, flush) |
| 19 | +# define deflateBound(strm, source_len) zng_deflateBound(strm, source_len) |
| 20 | +# define deflateEnd(strm) zng_deflateEnd(strm) |
| 21 | +# define deflateInit(strm, level) zng_deflateInit(strm, level) |
| 22 | +# define deflateInit2(stream, level, method, window_bits, mem_level, strategy) zng_deflateInit2(stream, level, method, window_bits, mem_level, strategy) |
| 23 | +# define deflateReset(strm) zng_deflateReset(strm) |
| 24 | +# define deflateSetHeader(strm, head) zng_deflateSetHeader(strm, head) |
| 25 | + |
| 26 | +#else |
| 27 | +# include <zlib.h> |
| 28 | + |
| 29 | +# if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200 |
| 30 | +# define deflateBound(c,s) ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11) |
| 31 | +# endif |
| 32 | + |
| 33 | +/* |
| 34 | + * zlib only gained support for setting up the gzip header in v1.2.2.1. In |
| 35 | + * Git we only set the header to make archives reproducible across different |
| 36 | + * operating systems, so it's fine to simply make this a no-op when using a |
| 37 | + * zlib version that doesn't support this yet. |
| 38 | + */ |
| 39 | +# if ZLIB_VERNUM < 0x1221 |
| 40 | +struct gz_header_s { |
| 41 | + int os; |
| 42 | +}; |
| 43 | + |
| 44 | +static int deflateSetHeader(z_streamp strm, struct gz_header_s *head) |
| 45 | +{ |
| 46 | + (void)(strm); |
| 47 | + (void)(head); |
| 48 | + return Z_OK; |
| 49 | +} |
| 50 | +# endif |
| 51 | +#endif /* HAVE_ZLIB_NG */ |
| 52 | + |
| 53 | +#endif /* COMPAT_ZLIB_H */ |
0 commit comments