]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - SQUASHFS/squashfs-tools-4.4/squashfs-tools/lzma_wrapper.c
2 * Copyright (c) 2009, 2010, 2013
3 * Phillip Lougher <phillip@squashfs.org.uk>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2,
8 * or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Support for LZMA1 compression using LZMA SDK (4.65 used in
22 * development, other versions may work) http://www.7-zip.org/sdk.html
27 #include "squashfs_fs.h"
28 #include "compressor.h"
30 #define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
32 static int lzma_compress(void *strm
, void *dest
, void *src
, int size
, int block_size
,
39 static int lzma_uncompress(void *dest
, void *src
, int size
, int outsize
,
42 unsigned char *s
= src
;
43 size_t outlen
, inlen
= size
- LZMA_HEADER_SIZE
;
46 outlen
= s
[LZMA_PROPS_SIZE
] |
47 (s
[LZMA_PROPS_SIZE
+ 1] << 8) |
48 (s
[LZMA_PROPS_SIZE
+ 2] << 16) |
49 (s
[LZMA_PROPS_SIZE
+ 3] << 24);
51 if(outlen
> outsize
) {
56 res
= LzmaUncompress(dest
, &outlen
, src
+ LZMA_HEADER_SIZE
, &inlen
, src
,
68 struct compressor lzma_comp_ops
= {
70 .compress
= lzma_compress
,
71 .uncompress
= lzma_uncompress
,
74 .id
= LZMA_COMPRESSION
,