example.c revision ada1678a4262b208a7b87391f520a7767d25287c
/* example.c -- usage example of the zlib compression library
* Copyright (C) 1995-2002 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include <stdio.h>
#include "zlib.h"
#ifdef STDC
# include <string.h>
# include <stdlib.h>
#else
#endif
# define TESTFILE "foo-gz"
#else
# define TESTFILE "foo.gz"
#endif
exit(1); \
} \
}
const char hello[] = "hello, hello!";
/* "hello world" would be more standard, but the repeated "hello"
* stresses the compression code better, sorry...
*/
const char dictionary[] = "hello";
/* ===========================================================================
* Test compress() and uncompress()
*/
{
int err;
exit(1);
} else {
}
}
/* ===========================================================================
*/
const char *out; /* compressed output file */
const char *in; /* compressed input file */
int uncomprLen;
{
int err;
exit(1);
}
exit(1);
}
exit(1);
}
}
if (uncomprLen != len) {
exit(1);
}
exit(1);
} else {
}
exit(1);
}
exit(1);
}
exit(1);
}
exit(1);
} else {
}
}
/* ===========================================================================
* Test deflate() with small buffers
*/
{
int err;
}
/* Finish the stream, still forcing small buffers: */
for (;;) {
if (err == Z_STREAM_END) break;
}
}
/* ===========================================================================
* Test inflate() with small buffers
*/
{
int err;
if (err == Z_STREAM_END) break;
}
exit(1);
} else {
}
}
/* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level
*/
{
int err;
/* At this point, uncompr is still mostly zeroes, so it should compress
* very well:
*/
exit(1);
}
/* Feed in already compressed data and switch to no compression: */
/* Switch back to compressing mode: */
if (err != Z_STREAM_END) {
exit(1);
}
}
/* ===========================================================================
* Test inflate() with large buffers
*/
{
int err;
for (;;) {
if (err == Z_STREAM_END) break;
}
exit(1);
} else {
printf("large_inflate(): OK\n");
}
}
/* ===========================================================================
* Test deflate() with full flush
*/
{
int err;
if (err != Z_STREAM_END) {
}
}
/* ===========================================================================
* Test inflateSync()
*/
{
int err;
if (err != Z_DATA_ERROR) {
/* Because of incorrect adler32 */
exit(1);
}
}
/* ===========================================================================
* Test deflate() with preset dictionary
*/
{
int err;
if (err != Z_STREAM_END) {
exit(1);
}
}
/* ===========================================================================
* Test inflate() with a preset dictionary
*/
{
int err;
for (;;) {
if (err == Z_STREAM_END) break;
if (err == Z_NEED_DICT) {
exit(1);
}
sizeof(dictionary));
}
}
exit(1);
} else {
}
}
/* ===========================================================================
* Usage: example [output.gz [input.gz]]
*/
int argc;
char *argv[];
{
static const char* myVersion = ZLIB_VERSION;
if (zlibVersion()[0] != myVersion[0]) {
exit(1);
}
/* compr and uncompr are cleared to avoid reading uninitialized
* data and to ensure that uncompr compresses well.
*/
printf("out of memory\n");
exit(1);
}
uncompr, (int)uncomprLen);
exit(0);
return 0; /* to avoid warning */
}