wok-6.x view linux/stuff/linux-lzma-export.u @ rev 310
Linux: export unlzma
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 02 20:47:57 2008 +0000 (2008-03-02) |
parents | |
children | 28bd53ce3a11 |
line source
1 --- linux-2.6.24.2/lib/decompress_unlzma.c
2 +++ linux-2.6.24.2/lib/decompress_unlzma.c
3 @@ -321,7 +321,7 @@ typedef struct {
4 #define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS)
7 -STATIC int unlzma(char *inbuf, int in_len,
8 +int unlzma(char *inbuf, int in_len,
9 int(*fill)(void*,unsigned int),
10 int(*writebb)(char*,unsigned int),
11 int *posp)
12 @@ -348,10 +348,21 @@ STATIC int unlzma(char *inbuf, int in_le
14 rc_init(&rc, fill, inbuf, in_len);
16 - for (i = 0; i < sizeof(header); i++) {
17 - if (rc.ptr >= rc.buffer_end)
18 - rc_read(&rc);
19 - ((unsigned char *)&header)[i] = *rc.ptr++;
20 + header.dict_size = header.dst_size = in_len;
21 + if (inbuf && inbuf[0] == 0) {
22 + const LZMA_LC = 3, LZMA_LP = 0, LZMA_PB = 2;
23 + header.pos = (LZMA_PB * 45) + (LZMA_LP * 5) + LZMA_LC;
24 + rc.ptr++;
25 + }
26 + else {
27 + int hdrsize = sizeof(header);
28 + if (inbuf && (1 + * (unsigned long *) &inbuf[9]) > 1U)
29 + hdrsize = 5;
30 + for (i = 0; i < hdrsize; i++) {
31 + if (rc.ptr >= rc.buffer_end)
32 + rc_read(&rc);
33 + ((unsigned char *)&header)[i] = *rc.ptr++;
34 + }
35 }
37 if (header.pos >= (9 * 5 * 5))
39 --- linux-2.6.24.2/lib/Makefile
40 +++ linux-2.6.24.2/lib/Makefile
41 @@ -51,7 +51,7 @@ obj-$(CONFIG_LIBCRC32C) += libcrc32c.o
42 obj-$(CONFIG_GENERIC_ALLOCATOR) += genalloc.o
44 obj-$(CONFIG_RD_BZIP2) += decompress_bunzip2.o
45 -obj-$(CONFIG_RD_LZMA) += decompress_unlzma.o
46 +obj-$(CONFIG_RD_LZMA) += decompress_unlzma.o unlzma_syms.o
49 obj-$(CONFIG_ZLIB_INFLATE) += zlib_inflate/
51 --- linux-2.6.24.2/lib/unlzma_syms.c
52 +++ linux-2.6.24.2/lib/unlzma_syms.c
53 @@ -0,0 +1,14 @@
54 +/*
55 + * linux/lib/unlzma_syms.c
56 + *
57 + * Exported symbols for the unlzma functionality.
58 + *
59 + */
60 +
61 +#include <linux/module.h>
62 +#include <linux/init.h>
63 +
64 +#include <linux/decompress_unlzma.h>
65 +
66 +EXPORT_SYMBOL(unlzma);
67 +MODULE_LICENSE("GPL");