1 /*
2 * Test application to test buffer-to-buffer decoding
3 *
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
5 *
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
8 */
9
10 #include <stdbool.h>
11 #include <stdio.h>
12 #include <string.h>
13 #include "xz.h"
14
15 #define BUFFER_SIZE (1024 * 1024)
16
17 static uint8_t in[BUFFER_SIZE];
18 static uint8_t out[BUFFER_SIZE];
19
main(void)20 int main(void)
21 {
22 struct xz_buf b;
23 struct xz_dec *s;
24 enum xz_ret ret;
25
26 xz_crc32_init();
27
28 s = xz_dec_init(XZ_SINGLE, 0);
29 if (s == NULL) {
30 fputs("Initialization failed\n", stderr);
31 return 1;
32 }
33
34 b.in = in;
35 b.in_pos = 0;
36 b.in_size = fread(in, 1, sizeof(in), stdin);
37
38 b.out = out;
39 b.out_pos = 0;
40 b.out_size = sizeof(out);
41
42 ret = xz_dec_run(s, &b);
43 xz_dec_end(s);
44
45 fwrite(out, 1, b.out_pos, stdout);
46 fprintf(stderr, "%d\n", ret);
47
48 return 0;
49 }
50