]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - Plugson/src/Lib/xz-embedded/userspace/bytetest.c
2 * Lazy test for the case when the output size is known
4 * Author: Lasse Collin <lasse.collin@tukaani.org>
6 * This file has been put into the public domain.
7 * You can do whatever you want with this file.
17 static uint8_t out
[BUFSIZ
];
19 int main(int argc
, char **argv
)
28 fputs("Give uncompressed size as the argument", stderr
);
32 uncomp_size
= atoi(argv
[1]);
37 * Support up to 64 MiB dictionary. The actually needed memory
38 * is allocated once the headers have been parsed.
40 s
= xz_dec_init(XZ_DYNALLOC
, 1 << 26);
42 msg
= "Memory allocation failed\n";
51 b
.out_size
= uncomp_size
< BUFSIZ
? uncomp_size
: BUFSIZ
;
54 if (b
.in_pos
== b
.in_size
) {
55 b
.in_size
= fread(in
, 1, sizeof(in
), stdin
);
59 ret
= xz_dec_run(s
, &b
);
61 if (b
.out_pos
== sizeof(out
)) {
62 if (fwrite(out
, 1, b
.out_pos
, stdout
) != b
.out_pos
) {
63 msg
= "Write error\n";
67 uncomp_size
-= b
.out_pos
;
69 b
.out_size
= uncomp_size
< BUFSIZ
70 ? uncomp_size
: BUFSIZ
;
76 #ifdef XZ_DEC_ANY_CHECK
77 if (ret
== XZ_UNSUPPORTED_CHECK
) {
78 fputs(argv
[0], stderr
);
80 fputs("Unsupported check; not verifying "
81 "file integrity\n", stderr
);
86 if (uncomp_size
!= b
.out_pos
) {
87 msg
= "Uncompressed size doesn't match\n";
91 if (fwrite(out
, 1, b
.out_pos
, stdout
) != b
.out_pos
93 msg
= "Write error\n";
103 msg
= "Memory allocation failed\n";
106 case XZ_MEMLIMIT_ERROR
:
107 msg
= "Memory usage limit reached\n";
110 case XZ_FORMAT_ERROR
:
111 msg
= "Not a .xz file\n";
114 case XZ_OPTIONS_ERROR
:
115 msg
= "Unsupported options in the .xz headers\n";
120 msg
= "File is corrupt\n";
131 fputs(argv
[0], stderr
);