Chris@4: /* example.c -- usage example of the zlib compression library Chris@4: * Copyright (C) 1995-2006, 2011 Jean-loup Gailly. Chris@4: * For conditions of distribution and use, see copyright notice in zlib.h Chris@4: */ Chris@4: Chris@4: /* @(#) $Id$ */ Chris@4: Chris@4: #include "zlib.h" Chris@4: #include Chris@4: Chris@4: #ifdef STDC Chris@4: # include Chris@4: # include Chris@4: #endif Chris@4: Chris@4: #if defined(VMS) || defined(RISCOS) Chris@4: # define TESTFILE "foo-gz" Chris@4: #else Chris@4: # define TESTFILE "foo.gz" Chris@4: #endif Chris@4: Chris@4: #define CHECK_ERR(err, msg) { \ Chris@4: if (err != Z_OK) { \ Chris@4: fprintf(stderr, "%s error: %d\n", msg, err); \ Chris@4: exit(1); \ Chris@4: } \ Chris@4: } Chris@4: Chris@4: const char hello[] = "hello, hello!"; Chris@4: /* "hello world" would be more standard, but the repeated "hello" Chris@4: * stresses the compression code better, sorry... Chris@4: */ Chris@4: Chris@4: const char dictionary[] = "hello"; Chris@4: uLong dictId; /* Adler32 value of the dictionary */ Chris@4: Chris@4: void test_deflate OF((Byte *compr, uLong comprLen)); Chris@4: void test_inflate OF((Byte *compr, uLong comprLen, Chris@4: Byte *uncompr, uLong uncomprLen)); Chris@4: void test_large_deflate OF((Byte *compr, uLong comprLen, Chris@4: Byte *uncompr, uLong uncomprLen)); Chris@4: void test_large_inflate OF((Byte *compr, uLong comprLen, Chris@4: Byte *uncompr, uLong uncomprLen)); Chris@4: void test_flush OF((Byte *compr, uLong *comprLen)); Chris@4: void test_sync OF((Byte *compr, uLong comprLen, Chris@4: Byte *uncompr, uLong uncomprLen)); Chris@4: void test_dict_deflate OF((Byte *compr, uLong comprLen)); Chris@4: void test_dict_inflate OF((Byte *compr, uLong comprLen, Chris@4: Byte *uncompr, uLong uncomprLen)); Chris@4: int main OF((int argc, char *argv[])); Chris@4: Chris@4: Chris@4: #ifdef Z_SOLO Chris@4: Chris@4: void *myalloc OF((void *, unsigned, unsigned)); Chris@4: void myfree OF((void *, void *)); Chris@4: Chris@4: void *myalloc(q, n, m) Chris@4: void *q; Chris@4: unsigned n, m; Chris@4: { Chris@4: q = Z_NULL; Chris@4: return calloc(n, m); Chris@4: } Chris@4: Chris@4: void myfree(void *q, void *p) Chris@4: { Chris@4: q = Z_NULL; Chris@4: free(p); Chris@4: } Chris@4: Chris@4: static alloc_func zalloc = myalloc; Chris@4: static free_func zfree = myfree; Chris@4: Chris@4: #else /* !Z_SOLO */ Chris@4: Chris@4: static alloc_func zalloc = (alloc_func)0; Chris@4: static free_func zfree = (free_func)0; Chris@4: Chris@4: void test_compress OF((Byte *compr, uLong comprLen, Chris@4: Byte *uncompr, uLong uncomprLen)); Chris@4: void test_gzio OF((const char *fname, Chris@4: Byte *uncompr, uLong uncomprLen)); Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test compress() and uncompress() Chris@4: */ Chris@4: void test_compress(compr, comprLen, uncompr, uncomprLen) Chris@4: Byte *compr, *uncompr; Chris@4: uLong comprLen, uncomprLen; Chris@4: { Chris@4: int err; Chris@4: uLong len = (uLong)strlen(hello)+1; Chris@4: Chris@4: err = compress(compr, &comprLen, (const Bytef*)hello, len); Chris@4: CHECK_ERR(err, "compress"); Chris@4: Chris@4: strcpy((char*)uncompr, "garbage"); Chris@4: Chris@4: err = uncompress(uncompr, &uncomprLen, compr, comprLen); Chris@4: CHECK_ERR(err, "uncompress"); Chris@4: Chris@4: if (strcmp((char*)uncompr, hello)) { Chris@4: fprintf(stderr, "bad uncompress\n"); Chris@4: exit(1); Chris@4: } else { Chris@4: printf("uncompress(): %s\n", (char *)uncompr); Chris@4: } Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test read/write of .gz files Chris@4: */ Chris@4: void test_gzio(fname, uncompr, uncomprLen) Chris@4: const char *fname; /* compressed file name */ Chris@4: Byte *uncompr; Chris@4: uLong uncomprLen; Chris@4: { Chris@4: #ifdef NO_GZCOMPRESS Chris@4: fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); Chris@4: #else Chris@4: int err; Chris@4: int len = (int)strlen(hello)+1; Chris@4: gzFile file; Chris@4: z_off_t pos; Chris@4: Chris@4: file = gzopen(fname, "wb"); Chris@4: if (file == NULL) { Chris@4: fprintf(stderr, "gzopen error\n"); Chris@4: exit(1); Chris@4: } Chris@4: gzputc(file, 'h'); Chris@4: if (gzputs(file, "ello") != 4) { Chris@4: fprintf(stderr, "gzputs err: %s\n", gzerror(file, &err)); Chris@4: exit(1); Chris@4: } Chris@4: if (gzprintf(file, ", %s!", "hello") != 8) { Chris@4: fprintf(stderr, "gzprintf err: %s\n", gzerror(file, &err)); Chris@4: exit(1); Chris@4: } Chris@4: gzseek(file, 1L, SEEK_CUR); /* add one zero byte */ Chris@4: gzclose(file); Chris@4: Chris@4: file = gzopen(fname, "rb"); Chris@4: if (file == NULL) { Chris@4: fprintf(stderr, "gzopen error\n"); Chris@4: exit(1); Chris@4: } Chris@4: strcpy((char*)uncompr, "garbage"); Chris@4: Chris@4: if (gzread(file, uncompr, (unsigned)uncomprLen) != len) { Chris@4: fprintf(stderr, "gzread err: %s\n", gzerror(file, &err)); Chris@4: exit(1); Chris@4: } Chris@4: if (strcmp((char*)uncompr, hello)) { Chris@4: fprintf(stderr, "bad gzread: %s\n", (char*)uncompr); Chris@4: exit(1); Chris@4: } else { Chris@4: printf("gzread(): %s\n", (char*)uncompr); Chris@4: } Chris@4: Chris@4: pos = gzseek(file, -8L, SEEK_CUR); Chris@4: if (pos != 6 || gztell(file) != pos) { Chris@4: fprintf(stderr, "gzseek error, pos=%ld, gztell=%ld\n", Chris@4: (long)pos, (long)gztell(file)); Chris@4: exit(1); Chris@4: } Chris@4: Chris@4: if (gzgetc(file) != ' ') { Chris@4: fprintf(stderr, "gzgetc error\n"); Chris@4: exit(1); Chris@4: } Chris@4: Chris@4: if (gzungetc(' ', file) != ' ') { Chris@4: fprintf(stderr, "gzungetc error\n"); Chris@4: exit(1); Chris@4: } Chris@4: Chris@4: gzgets(file, (char*)uncompr, (int)uncomprLen); Chris@4: if (strlen((char*)uncompr) != 7) { /* " hello!" */ Chris@4: fprintf(stderr, "gzgets err after gzseek: %s\n", gzerror(file, &err)); Chris@4: exit(1); Chris@4: } Chris@4: if (strcmp((char*)uncompr, hello + 6)) { Chris@4: fprintf(stderr, "bad gzgets after gzseek\n"); Chris@4: exit(1); Chris@4: } else { Chris@4: printf("gzgets() after gzseek: %s\n", (char*)uncompr); Chris@4: } Chris@4: Chris@4: gzclose(file); Chris@4: #endif Chris@4: } Chris@4: Chris@4: #endif /* Z_SOLO */ Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test deflate() with small buffers Chris@4: */ Chris@4: void test_deflate(compr, comprLen) Chris@4: Byte *compr; Chris@4: uLong comprLen; Chris@4: { Chris@4: z_stream c_stream; /* compression stream */ Chris@4: int err; Chris@4: uLong len = (uLong)strlen(hello)+1; Chris@4: Chris@4: c_stream.zalloc = zalloc; Chris@4: c_stream.zfree = zfree; Chris@4: c_stream.opaque = (voidpf)0; Chris@4: Chris@4: err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); Chris@4: CHECK_ERR(err, "deflateInit"); Chris@4: Chris@4: c_stream.next_in = (Bytef*)hello; Chris@4: c_stream.next_out = compr; Chris@4: Chris@4: while (c_stream.total_in != len && c_stream.total_out < comprLen) { Chris@4: c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ Chris@4: err = deflate(&c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, "deflate"); Chris@4: } Chris@4: /* Finish the stream, still forcing small buffers: */ Chris@4: for (;;) { Chris@4: c_stream.avail_out = 1; Chris@4: err = deflate(&c_stream, Z_FINISH); Chris@4: if (err == Z_STREAM_END) break; Chris@4: CHECK_ERR(err, "deflate"); Chris@4: } Chris@4: Chris@4: err = deflateEnd(&c_stream); Chris@4: CHECK_ERR(err, "deflateEnd"); Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test inflate() with small buffers Chris@4: */ Chris@4: void test_inflate(compr, comprLen, uncompr, uncomprLen) Chris@4: Byte *compr, *uncompr; Chris@4: uLong comprLen, uncomprLen; Chris@4: { Chris@4: int err; Chris@4: z_stream d_stream; /* decompression stream */ Chris@4: Chris@4: strcpy((char*)uncompr, "garbage"); Chris@4: Chris@4: d_stream.zalloc = zalloc; Chris@4: d_stream.zfree = zfree; Chris@4: d_stream.opaque = (voidpf)0; Chris@4: Chris@4: d_stream.next_in = compr; Chris@4: d_stream.avail_in = 0; Chris@4: d_stream.next_out = uncompr; Chris@4: Chris@4: err = inflateInit(&d_stream); Chris@4: CHECK_ERR(err, "inflateInit"); Chris@4: Chris@4: while (d_stream.total_out < uncomprLen && d_stream.total_in < comprLen) { Chris@4: d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ Chris@4: err = inflate(&d_stream, Z_NO_FLUSH); Chris@4: if (err == Z_STREAM_END) break; Chris@4: CHECK_ERR(err, "inflate"); Chris@4: } Chris@4: Chris@4: err = inflateEnd(&d_stream); Chris@4: CHECK_ERR(err, "inflateEnd"); Chris@4: Chris@4: if (strcmp((char*)uncompr, hello)) { Chris@4: fprintf(stderr, "bad inflate\n"); Chris@4: exit(1); Chris@4: } else { Chris@4: printf("inflate(): %s\n", (char *)uncompr); Chris@4: } Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test deflate() with large buffers and dynamic change of compression level Chris@4: */ Chris@4: void test_large_deflate(compr, comprLen, uncompr, uncomprLen) Chris@4: Byte *compr, *uncompr; Chris@4: uLong comprLen, uncomprLen; Chris@4: { Chris@4: z_stream c_stream; /* compression stream */ Chris@4: int err; Chris@4: Chris@4: c_stream.zalloc = zalloc; Chris@4: c_stream.zfree = zfree; Chris@4: c_stream.opaque = (voidpf)0; Chris@4: Chris@4: err = deflateInit(&c_stream, Z_BEST_SPEED); Chris@4: CHECK_ERR(err, "deflateInit"); Chris@4: Chris@4: c_stream.next_out = compr; Chris@4: c_stream.avail_out = (uInt)comprLen; Chris@4: Chris@4: /* At this point, uncompr is still mostly zeroes, so it should compress Chris@4: * very well: Chris@4: */ Chris@4: c_stream.next_in = uncompr; Chris@4: c_stream.avail_in = (uInt)uncomprLen; Chris@4: err = deflate(&c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, "deflate"); Chris@4: if (c_stream.avail_in != 0) { Chris@4: fprintf(stderr, "deflate not greedy\n"); Chris@4: exit(1); Chris@4: } Chris@4: Chris@4: /* Feed in already compressed data and switch to no compression: */ Chris@4: deflateParams(&c_stream, Z_NO_COMPRESSION, Z_DEFAULT_STRATEGY); Chris@4: c_stream.next_in = compr; Chris@4: c_stream.avail_in = (uInt)comprLen/2; Chris@4: err = deflate(&c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, "deflate"); Chris@4: Chris@4: /* Switch back to compressing mode: */ Chris@4: deflateParams(&c_stream, Z_BEST_COMPRESSION, Z_FILTERED); Chris@4: c_stream.next_in = uncompr; Chris@4: c_stream.avail_in = (uInt)uncomprLen; Chris@4: err = deflate(&c_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, "deflate"); Chris@4: Chris@4: err = deflate(&c_stream, Z_FINISH); Chris@4: if (err != Z_STREAM_END) { Chris@4: fprintf(stderr, "deflate should report Z_STREAM_END\n"); Chris@4: exit(1); Chris@4: } Chris@4: err = deflateEnd(&c_stream); Chris@4: CHECK_ERR(err, "deflateEnd"); Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test inflate() with large buffers Chris@4: */ Chris@4: void test_large_inflate(compr, comprLen, uncompr, uncomprLen) Chris@4: Byte *compr, *uncompr; Chris@4: uLong comprLen, uncomprLen; Chris@4: { Chris@4: int err; Chris@4: z_stream d_stream; /* decompression stream */ Chris@4: Chris@4: strcpy((char*)uncompr, "garbage"); Chris@4: Chris@4: d_stream.zalloc = zalloc; Chris@4: d_stream.zfree = zfree; Chris@4: d_stream.opaque = (voidpf)0; Chris@4: Chris@4: d_stream.next_in = compr; Chris@4: d_stream.avail_in = (uInt)comprLen; Chris@4: Chris@4: err = inflateInit(&d_stream); Chris@4: CHECK_ERR(err, "inflateInit"); Chris@4: Chris@4: for (;;) { Chris@4: d_stream.next_out = uncompr; /* discard the output */ Chris@4: d_stream.avail_out = (uInt)uncomprLen; Chris@4: err = inflate(&d_stream, Z_NO_FLUSH); Chris@4: if (err == Z_STREAM_END) break; Chris@4: CHECK_ERR(err, "large inflate"); Chris@4: } Chris@4: Chris@4: err = inflateEnd(&d_stream); Chris@4: CHECK_ERR(err, "inflateEnd"); Chris@4: Chris@4: if (d_stream.total_out != 2*uncomprLen + comprLen/2) { Chris@4: fprintf(stderr, "bad large inflate: %ld\n", d_stream.total_out); Chris@4: exit(1); Chris@4: } else { Chris@4: printf("large_inflate(): OK\n"); Chris@4: } Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test deflate() with full flush Chris@4: */ Chris@4: void test_flush(compr, comprLen) Chris@4: Byte *compr; Chris@4: uLong *comprLen; Chris@4: { Chris@4: z_stream c_stream; /* compression stream */ Chris@4: int err; Chris@4: uInt len = (uInt)strlen(hello)+1; Chris@4: Chris@4: c_stream.zalloc = zalloc; Chris@4: c_stream.zfree = zfree; Chris@4: c_stream.opaque = (voidpf)0; Chris@4: Chris@4: err = deflateInit(&c_stream, Z_DEFAULT_COMPRESSION); Chris@4: CHECK_ERR(err, "deflateInit"); Chris@4: Chris@4: c_stream.next_in = (Bytef*)hello; Chris@4: c_stream.next_out = compr; Chris@4: c_stream.avail_in = 3; Chris@4: c_stream.avail_out = (uInt)*comprLen; Chris@4: err = deflate(&c_stream, Z_FULL_FLUSH); Chris@4: CHECK_ERR(err, "deflate"); Chris@4: Chris@4: compr[3]++; /* force an error in first compressed block */ Chris@4: c_stream.avail_in = len - 3; Chris@4: Chris@4: err = deflate(&c_stream, Z_FINISH); Chris@4: if (err != Z_STREAM_END) { Chris@4: CHECK_ERR(err, "deflate"); Chris@4: } Chris@4: err = deflateEnd(&c_stream); Chris@4: CHECK_ERR(err, "deflateEnd"); Chris@4: Chris@4: *comprLen = c_stream.total_out; Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test inflateSync() Chris@4: */ Chris@4: void test_sync(compr, comprLen, uncompr, uncomprLen) Chris@4: Byte *compr, *uncompr; Chris@4: uLong comprLen, uncomprLen; Chris@4: { Chris@4: int err; Chris@4: z_stream d_stream; /* decompression stream */ Chris@4: Chris@4: strcpy((char*)uncompr, "garbage"); Chris@4: Chris@4: d_stream.zalloc = zalloc; Chris@4: d_stream.zfree = zfree; Chris@4: d_stream.opaque = (voidpf)0; Chris@4: Chris@4: d_stream.next_in = compr; Chris@4: d_stream.avail_in = 2; /* just read the zlib header */ Chris@4: Chris@4: err = inflateInit(&d_stream); Chris@4: CHECK_ERR(err, "inflateInit"); Chris@4: Chris@4: d_stream.next_out = uncompr; Chris@4: d_stream.avail_out = (uInt)uncomprLen; Chris@4: Chris@4: inflate(&d_stream, Z_NO_FLUSH); Chris@4: CHECK_ERR(err, "inflate"); Chris@4: Chris@4: d_stream.avail_in = (uInt)comprLen-2; /* read all compressed data */ Chris@4: err = inflateSync(&d_stream); /* but skip the damaged part */ Chris@4: CHECK_ERR(err, "inflateSync"); Chris@4: Chris@4: err = inflate(&d_stream, Z_FINISH); Chris@4: if (err != Z_DATA_ERROR) { Chris@4: fprintf(stderr, "inflate should report DATA_ERROR\n"); Chris@4: /* Because of incorrect adler32 */ Chris@4: exit(1); Chris@4: } Chris@4: err = inflateEnd(&d_stream); Chris@4: CHECK_ERR(err, "inflateEnd"); Chris@4: Chris@4: printf("after inflateSync(): hel%s\n", (char *)uncompr); Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test deflate() with preset dictionary Chris@4: */ Chris@4: void test_dict_deflate(compr, comprLen) Chris@4: Byte *compr; Chris@4: uLong comprLen; Chris@4: { Chris@4: z_stream c_stream; /* compression stream */ Chris@4: int err; Chris@4: Chris@4: c_stream.zalloc = zalloc; Chris@4: c_stream.zfree = zfree; Chris@4: c_stream.opaque = (voidpf)0; Chris@4: Chris@4: err = deflateInit(&c_stream, Z_BEST_COMPRESSION); Chris@4: CHECK_ERR(err, "deflateInit"); Chris@4: Chris@4: err = deflateSetDictionary(&c_stream, Chris@4: (const Bytef*)dictionary, (int)sizeof(dictionary)); Chris@4: CHECK_ERR(err, "deflateSetDictionary"); Chris@4: Chris@4: dictId = c_stream.adler; Chris@4: c_stream.next_out = compr; Chris@4: c_stream.avail_out = (uInt)comprLen; Chris@4: Chris@4: c_stream.next_in = (Bytef*)hello; Chris@4: c_stream.avail_in = (uInt)strlen(hello)+1; Chris@4: Chris@4: err = deflate(&c_stream, Z_FINISH); Chris@4: if (err != Z_STREAM_END) { Chris@4: fprintf(stderr, "deflate should report Z_STREAM_END\n"); Chris@4: exit(1); Chris@4: } Chris@4: err = deflateEnd(&c_stream); Chris@4: CHECK_ERR(err, "deflateEnd"); Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Test inflate() with a preset dictionary Chris@4: */ Chris@4: void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) Chris@4: Byte *compr, *uncompr; Chris@4: uLong comprLen, uncomprLen; Chris@4: { Chris@4: int err; Chris@4: z_stream d_stream; /* decompression stream */ Chris@4: Chris@4: strcpy((char*)uncompr, "garbage"); Chris@4: Chris@4: d_stream.zalloc = zalloc; Chris@4: d_stream.zfree = zfree; Chris@4: d_stream.opaque = (voidpf)0; Chris@4: Chris@4: d_stream.next_in = compr; Chris@4: d_stream.avail_in = (uInt)comprLen; Chris@4: Chris@4: err = inflateInit(&d_stream); Chris@4: CHECK_ERR(err, "inflateInit"); Chris@4: Chris@4: d_stream.next_out = uncompr; Chris@4: d_stream.avail_out = (uInt)uncomprLen; Chris@4: Chris@4: for (;;) { Chris@4: err = inflate(&d_stream, Z_NO_FLUSH); Chris@4: if (err == Z_STREAM_END) break; Chris@4: if (err == Z_NEED_DICT) { Chris@4: if (d_stream.adler != dictId) { Chris@4: fprintf(stderr, "unexpected dictionary"); Chris@4: exit(1); Chris@4: } Chris@4: err = inflateSetDictionary(&d_stream, (const Bytef*)dictionary, Chris@4: (int)sizeof(dictionary)); Chris@4: } Chris@4: CHECK_ERR(err, "inflate with dict"); Chris@4: } Chris@4: Chris@4: err = inflateEnd(&d_stream); Chris@4: CHECK_ERR(err, "inflateEnd"); Chris@4: Chris@4: if (strcmp((char*)uncompr, hello)) { Chris@4: fprintf(stderr, "bad inflate with dict\n"); Chris@4: exit(1); Chris@4: } else { Chris@4: printf("inflate with dictionary: %s\n", (char *)uncompr); Chris@4: } Chris@4: } Chris@4: Chris@4: /* =========================================================================== Chris@4: * Usage: example [output.gz [input.gz]] Chris@4: */ Chris@4: Chris@4: int main(argc, argv) Chris@4: int argc; Chris@4: char *argv[]; Chris@4: { Chris@4: Byte *compr, *uncompr; Chris@4: uLong comprLen = 10000*sizeof(int); /* don't overflow on MSDOS */ Chris@4: uLong uncomprLen = comprLen; Chris@4: static const char* myVersion = ZLIB_VERSION; Chris@4: Chris@4: if (zlibVersion()[0] != myVersion[0]) { Chris@4: fprintf(stderr, "incompatible zlib version\n"); Chris@4: exit(1); Chris@4: Chris@4: } else if (strcmp(zlibVersion(), ZLIB_VERSION) != 0) { Chris@4: fprintf(stderr, "warning: different zlib version\n"); Chris@4: } Chris@4: Chris@4: printf("zlib version %s = 0x%04x, compile flags = 0x%lx\n", Chris@4: ZLIB_VERSION, ZLIB_VERNUM, zlibCompileFlags()); Chris@4: Chris@4: compr = (Byte*)calloc((uInt)comprLen, 1); Chris@4: uncompr = (Byte*)calloc((uInt)uncomprLen, 1); Chris@4: /* compr and uncompr are cleared to avoid reading uninitialized Chris@4: * data and to ensure that uncompr compresses well. Chris@4: */ Chris@4: if (compr == Z_NULL || uncompr == Z_NULL) { Chris@4: printf("out of memory\n"); Chris@4: exit(1); Chris@4: } Chris@4: Chris@4: #ifdef Z_SOLO Chris@4: argc = strlen(argv[0]); Chris@4: #else Chris@4: test_compress(compr, comprLen, uncompr, uncomprLen); Chris@4: Chris@4: test_gzio((argc > 1 ? argv[1] : TESTFILE), Chris@4: uncompr, uncomprLen); Chris@4: #endif Chris@4: Chris@4: test_deflate(compr, comprLen); Chris@4: test_inflate(compr, comprLen, uncompr, uncomprLen); Chris@4: Chris@4: test_large_deflate(compr, comprLen, uncompr, uncomprLen); Chris@4: test_large_inflate(compr, comprLen, uncompr, uncomprLen); Chris@4: Chris@4: test_flush(compr, &comprLen); Chris@4: test_sync(compr, comprLen, uncompr, uncomprLen); Chris@4: comprLen = uncomprLen; Chris@4: Chris@4: test_dict_deflate(compr, comprLen); Chris@4: test_dict_inflate(compr, comprLen, uncompr, uncomprLen); Chris@4: Chris@4: free(compr); Chris@4: free(uncompr); Chris@4: Chris@4: return 0; Chris@4: }