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 @@ -90,6 +90,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 +#ifdef CONFIG_RLE_DECOMPRESS
30 +int rle_decode(const unsigned char *src, size_t srclen,
31 + unsigned char *dst, size_t dstlen,
32 + size_t *src_done, size_t *dst_done);
35 +rle_decode(const unsigned char *src, size_t srclen,
36 + unsigned char *dst, size_t dstlen,
37 + size_t *src_done, size_t *dst_done)
41 +#endif /* CONFIG_RLE_DECOMPRESS */
48 + * RLE decoding routine
50 + * Copyright (C) 2012 Gabor Juhos <juhosg@openwrt.org>
52 + * This program is free software; you can redistribute it and/or modify it
53 + * under the terms of the GNU General Public License version 2 as published
54 + * by the Free Software Foundation.
57 +#include <linux/kernel.h>
58 +#include <linux/module.h>
59 +#include <linux/rle.h>
61 +int rle_decode(const unsigned char *src, size_t srclen,
62 + unsigned char *dst, size_t dstlen,
63 + size_t *src_done, size_t *dst_done)
65 + size_t srcpos, dstpos;
73 + if (!src || !srclen || !dst || !dstlen)
79 + if (srcpos >= srclen)
82 + count = (char) src[srcpos++];
91 + if (srcpos >= srclen)
97 + if (dstpos >= dstlen)
106 + if (srcpos >= srclen)
108 + if (dstpos >= dstlen)
110 + dst[dstpos++] = src[srcpos++];
117 + *src_done = srcpos;
119 + *dst_done = dstpos;
124 +EXPORT_SYMBOL_GPL(rle_decode);