diff options
author | Adrian Chadd <adrian@FreeBSD.org> | 2011-12-31 22:35:46 +0000 |
---|---|---|
committer | Adrian Chadd <adrian@FreeBSD.org> | 2011-12-31 22:35:46 +0000 |
commit | 38f44a8c7c3367df45180852ee34d7d0a81b4ed7 (patch) | |
tree | 944912fd7cd4c5579637a369ce7483e251516f82 /userspace/buftest.c |
Import xz-embedded from git.vendor/xz-embedded/48f4588342f4a4e0182a6740e25675fd8e6c6295
This is from commit hash '48f4588342f4a4e0182a6740e25675fd8e6c6295'.
Notes
Notes:
svn path=/vendor/xz-embedded/dist/; revision=229159
svn path=/vendor/xz-embedded/48f4588342f4a4e0182a6740e25675fd8e6c6295/; revision=229160; tag=vendor/xz-embedded/48f4588342f4a4e0182a6740e25675fd8e6c6295
Diffstat (limited to 'userspace/buftest.c')
-rw-r--r-- | userspace/buftest.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/userspace/buftest.c b/userspace/buftest.c new file mode 100644 index 000000000000..54b780ac243b --- /dev/null +++ b/userspace/buftest.c @@ -0,0 +1,48 @@ +/* + * Test application to test buffer-to-buffer decoding + * + * Author: Lasse Collin <lasse.collin@tukaani.org> + * + * This file has been put into the public domain. + * You can do whatever you want with this file. + */ + +#include <stdbool.h> +#include <stdio.h> +#include <string.h> +#include "xz.h" + +#define BUFFER_SIZE (1024 * 1024) + +static uint8_t in[BUFFER_SIZE]; +static uint8_t out[BUFFER_SIZE]; + +int main(void) +{ + struct xz_buf b; + struct xz_dec *s; + enum xz_ret ret; + + xz_crc32_init(); + + s = xz_dec_init(XZ_SINGLE, 0); + if (s == NULL) { + fputs("Initialization failed", stderr); + return 1; + } + + b.in = in; + b.in_pos = 0; + b.in_size = fread(in, 1, sizeof(in), stdin); + b.out = out; + b.out_pos = 0; + b.out_size = sizeof(out); + + ret = xz_dec_run(s, &b); + xz_dec_end(s); + + fwrite(out, 1, b.out_pos, stdout); + fprintf(stderr, "%d\n", ret); + + return 0; +} |