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