linux/lib/decompress.c
<<
8" 8" 8"o/spa3.48"ospa3 class="lxr_search">8" 8" 8" 8" typ Search.4 8" 8"o/spa3.4 8"oinput typ 8 4 odiv id/ /1o/a>ospa3 class="comment">/*o/spa3.4/ /2o/a>ospa3 class="comment"> * decompress.co/spa3.4/ /3o/a>ospa3 class="comment"> *o/spa3.4/ /4o/a>ospa3 class="comment"> * Detect the decompresson> method based n> magic numbero/spa3.4/ /5o/a>ospa3 class="comment"> */o/spa3.4/ /6o/a>8/ /7o/a>#include <linux/decompress/generic.ho/a>>8/ /8o/a>8/ /9o/a>#include <linux/decompress/bunzip2.ho/a>>8/ .9" a>#include <linux/decompress/unlzma.ho/a>>8/ 11" a>#include <linux/decompress/unxz.ho/a>>8/ 12" a>#include <linux/decompress/inflate.ho/a>>8/ 13" a>#include <linux/decompress/unlzo.ho/a>>8/ 14o/a>8/ 15" a>#include <linux/typ s.ho/a>>8/ 16" a>#include <linux/string.ho/a>>8/ 17o/a>#include <linux/init.ho/a>>8/ 18o/a>8/ 19o/a>#ifndef/oa href="+code=CONFIG_DECOMPRESS_GZIP" class="sref">CONFIG_DECOMPRESS_GZIPo/a>8/ 29" a># define/oa href="+code=gunzip" class="sref">gunzip" a>/oa href="+code=NULL" class="sref">NULLo/a>8/ 21" a>#endif8/ 22o/a>#ifndef/oa href="+code=CONFIG_DECOMPRESS_BZIP2" class="sref">CONFIG_DECOMPRESS_BZIP2o/a>8/ 23" a># define/oa href="+code=bunzip2" class="sref">bunzip2" a>/oa href="+code=NULL" class="sref">NULLo/a>8/ 24" a>#endif8/ 25o/a>#ifndef/oa href="+code=CONFIG_DECOMPRESS_LZMA" class="sref">CONFIG_DECOMPRESS_LZMAo/a>8/ 26" a># define/oa href="+code=unlzma" class="sref">unlzma" a>/oa href="+code=NULL" class="sref">NULLo/a>8/ 27" a>#endif8/ 28o/a>#ifndef/oa href="+code=CONFIG_DECOMPRESS_XZ" class="sref">CONFIG_DECOMPRESS_XZo/a>8/ 29" a># define/oa href="+code=unxz" class="sref">unxz" a>/oa href="+code=NULL" class="sref">NULLo/a>8/ 30" a>#endif8/ 31o/a>#ifndef/oa href="+code=CONFIG_DECOMPRESS_LZO" class="sref">CONFIG_DECOMPRESS_LZOo/a>8/ 32" a># define/oa href="+code=unlzo" class="sref">unlzo" a>/oa href="+code=NULL" class="sref">NULLo/a>8/ 33" a>#endif8/ 34o/a>8/ 35o/a>struct/oa href="+code=compress_format" class="sref">compress_format" a>/{8/ 36" a> unsigned char/oa href="+code=magic" class="sref">magic" a>[2];8/ 37" a> const char/*oa href="+code=nam " class="sref">nam " a>;8/ 38" a> oa href="+code=decompress_fn" class="sref">decompress_fn" a>/oa href="+code=decompressor" class="sref">decompressor" a>;8/ 39" a>};8/ 40o/a>8/ 41o/a>static const struct/oa href="+code=compress_format" class="sref">compress_format" a>/oa href="+code=compressed_formats" class="sref">compressed_formats" a>[]/oa href="+code=__initdata" class="sref">__initdata" a>/=/{8/ 42" a> { {037, 0213}, ospa3 class="string">"gzip"o/spa3.,/oa href="+code=gunzip" class="sref">gunzip" a>/},8/ 43" a> { {037, 0236}, ospa3 class="string">"gzip"o/spa3.,/oa href="+code=gunzip" class="sref">gunzip" a>/},8/ 44" a> { {0x42, 0x5a}, ospa3 class="string">"bzip2"o/spa3.,/oa href="+code=bunzip2" class="sref">bunzip2" a>/},8/ 45" a> { {0x5d, 0x00}, ospa3 class="string">"lzma"o/spa3.,/oa href="+code=unlzma" class="sref">unlzma" a>/},8/ 46" a> { {0xfd, 0x37}, ospa3 class="string">"xz"o/spa3.,/oa href="+code=unxz" class="sref">unxz" a>/},8/ 47" a> { {0x89, 0x4c}, ospa3 class="string">"lzo"o/spa3.,/oa href="+code=unlzo" class="sref">unlzo" a>/},8/ 48" a> { {0, 0},/oa href="+code=NULL" class="sref">NULLo/a>,/oa href="+code=NULL" class="sref">NULLo/a> }8/ 49" a>};8/ 50o/a>8/ 51o/a>oa href="+code=decompress_fn" class="sref">decompress_fn" a>/oa href="+code=__init" class="sref">__init" a>/oa href="+code=decompress_method" class="sref">decompress_method" a>(const unsigned char/*oa href="+code=inbuf" class="sref">inbufo/a>,/int/oa href="+code=len" class="sref">leno/a>,8/ 52" a> const char/**oa href="+code=nam " class="sref">nam " a>)8/ 53" a>{8/ 54" a> const struct/oa href="+code=compress_format" class="sref">compress_format" a>/*oa href="+code=cf" class="sref">cf" a>;8/ 55o/a>8/ 56" a> if (oa href="+code=len" class="sref">leno/a> < 2)8/ 57" a> return oa href="+code=NULL" class="sref">NULLo/a>; ospa3 class="comment">/* Need at least this much... */o/spa3.4/ 58o/a>8/ 59" a> for (oa href="+code=cf" class="sref">cf" a>/=/oa href="+code=compressed_formats" class="sref">compressed_formats" a>;/oa href="+code=cf" class="sref">cf" a>->oa href="+code=nam " class="sref">nam " a>;/oa href="+code=cf" class="sref">cf" a>++)/{8/ 60" a> if (!oa href="+code=memcmp" class="sref">memcmp" a>(oa href="+code=inbuf" class="sref">inbufo/a>,/oa href="+code=cf" class="sref">cf" a>->oa href="+code=magic" class="sref">magic" a>, 2))8/ 61" a> break;8/ 62o/a>8/ 63" a> }8/ 64" a> if (oa href="+code=nam " class="sref">nam " a>)8/ 65" a> *oa href="+code=nam " class="sref">nam " a>/=/oa href="+code=cf" class="sref">cf" a>->oa href="+code=nam " class="sref">nam " a>;8/ 66" a> return oa href="+code=cf" class="sref">cf" a>->oa href="+code=decompressor" class="sref">decompressor" a>;8/ 67" a>}8/ 68o/a> The original LXR software by the LXR community" a>, this experimental verson> by lxr@linux.no" a>. o/div.4odiv class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS" a>, provider of Linux consulting and opera v3s services since 1995. o/div.4 o/body.4o/html.4