3 @@ -197,6 +197,9 @@ config LZMA_COMPRESS
11 # These all provide a common interface (hence the apparent duplication with
12 # ZLIB_INFLATE; DECOMPRESS_GZIP is just a wrapper.)
15 @@ -89,6 +89,7 @@ obj-$(CONFIG_XZ_DEC) += xz/
16 obj-$(CONFIG_RAID6_PQ) += raid6/
17 obj-$(CONFIG_LZMA_COMPRESS) += lzma/
18 obj-$(CONFIG_LZMA_DECOMPRESS) += lzma/
19 +obj-$(CONFIG_RLE_DECOMPRESS) += rle.o
21 lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
22 lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
24 +++ b/include/linux/rle.h
29 +int rle_decode(const unsigned char *src, size_t srclen,
30 + unsigned char *dst, size_t dstlen,
31 + size_t *src_done, size_t *dst_done);
38 + * RLE decoding routine
40 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
42 + * This program is free software; you can redistribute it and/or modify it
43 + * under the terms of the GNU General Public License version 2 as published
44 + * by the Free Software Foundation.
47 +#include <linux/kernel.h>
48 +#include <linux/module.h>
49 +#include <linux/rle.h>
51 +int rle_decode(const unsigned char *src, size_t srclen,
52 + unsigned char *dst, size_t dstlen,
53 + size_t *src_done, size_t *dst_done)
55 + size_t srcpos, dstpos;
63 + if (!src || !srclen || !dst || !dstlen)
69 + if (srcpos >= srclen)
72 + count = (char) src[srcpos++];
81 + if (srcpos >= srclen)
87 + if (dstpos >= dstlen)
96 + if (srcpos >= srclen)
98 + if (dstpos >= dstlen)
100 + dst[dstpos++] = src[srcpos++];
107 + *src_done = srcpos;
109 + *dst_done = dstpos;
114 +EXPORT_SYMBOL_GPL(rle_decode);