]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - LinuxGUI/Ventoy2Disk/Lib/xz-embedded/userspace/xzminidec.c
2 * Simple XZ decoder command line tool
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.
11 * This is really limited: Not all filters from .xz format are supported,
12 * only CRC32 is supported as the integrity check, and decoding of
13 * concatenated .xz streams is not supported. Thus, you may want to look
14 * at xzdec from XZ Utils if a few KiB bigger tool is not a problem.
22 static uint8_t in
[BUFSIZ
];
23 static uint8_t out
[BUFSIZ
];
25 int main(int argc
, char **argv
)
32 if (argc
>= 2 && strcmp(argv
[1], "--help") == 0) {
33 fputs("Uncompress a .xz file from stdin to stdout.\n"
34 "Arguments other than `--help' are ignored.\n",
45 * Support up to 64 MiB dictionary. The actually needed memory
46 * is allocated once the headers have been parsed.
48 s
= xz_dec_init(XZ_DYNALLOC
, 1 << 26);
50 msg
= "Memory allocation failed\n";
62 if (b
.in_pos
== b
.in_size
) {
63 b
.in_size
= fread(in
, 1, sizeof(in
), stdin
);
67 ret
= xz_dec_run(s
, &b
);
69 if (b
.out_pos
== sizeof(out
)) {
70 if (fwrite(out
, 1, b
.out_pos
, stdout
) != b
.out_pos
) {
71 msg
= "Write error\n";
81 #ifdef XZ_DEC_ANY_CHECK
82 if (ret
== XZ_UNSUPPORTED_CHECK
) {
83 fputs(argv
[0], stderr
);
85 fputs("Unsupported check; not verifying "
86 "file integrity\n", stderr
);
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
);