2 * :make compdecomp CFLAGS=-Wall LDFLAGS=-lz
8 #define MEM_LIMIT (128*1024*1024)
10 int main(int argc, char *argv[])
18 printf("usage: %s <0|1> <infile> <outfile>\n", argv[0]);
22 fi = fopen(argv[2], "rb");
23 if (fi == NULL) return 2;
25 fseek(fi, 0, SEEK_END);
27 fseek(fi, 0, SEEK_SET);
29 if (pi == NULL) return 3;
40 if (so > MEM_LIMIT) return 4;
42 if (po == NULL) return 5;
43 ret = uncompress(po, (uLongf *) &so, pi, si);
45 while (ret == Z_BUF_ERROR);
52 if (po == NULL) return 5;
53 ret = compress2(po, (uLongf *) &so, pi, si, Z_BEST_COMPRESSION);
58 fo = fopen(argv[3], "wb");
59 if (fo == NULL) return 6;
60 fwrite(po, 1, so, fo);
64 printf("result %i, size %i -> %i\n", ret, si, so);