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