summaryrefslogtreecommitdiff
path: root/test/inflate-app.c
blob: dddc80739a9dc7360730deaac087ddd20d735f41 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>

#include "inflate.h"

unsigned char *inbuf;
unsigned char *outbuf;

int main(void)
{
	// 16 MB
	inbuf = malloc(4096 * 4096);
	outbuf = malloc(4096 * 4096);

	if (inbuf == NULL || outbuf == NULL) {
		return 1;
	}

	size_t in_size = fread(inbuf, 1, 4096 * 4096, stdin);

	if (in_size == 0) {
		return 1;
	}

	int16_t out_size = inflate_zlib(inbuf, in_size, outbuf, 65535);

	if (out_size < 0) {
		return -out_size;
	}

	fwrite(outbuf, 1, out_size, stdout);

	return 0;
}