1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file raw_decoder.c
4 /// \brief Raw decoder initialization API
6 // Copyright (C) 2007 Lasse Collin
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 ///////////////////////////////////////////////////////////////////////////////
20 #include "raw_decoder.h"
21 #include "copy_coder.h"
22 #include "simple_coder.h"
23 #include "subblock_decoder.h"
24 #include "subblock_decoder_helper.h"
25 #include "delta_coder.h"
26 #include "lzma_decoder.h"
27 #include "metadata_decoder.h"
30 static lzma_init_function
31 get_function(lzma_vli id)
34 #ifdef HAVE_FILTER_COPY
35 case LZMA_FILTER_COPY:
36 return &lzma_copy_decoder_init;
39 #ifdef HAVE_FILTER_SUBBLOCK
40 case LZMA_FILTER_SUBBLOCK:
41 return &lzma_subblock_decoder_init;
44 #ifdef HAVE_FILTER_X86
46 return &lzma_simple_x86_decoder_init;
49 #ifdef HAVE_FILTER_POWERPC
50 case LZMA_FILTER_POWERPC:
51 return &lzma_simple_powerpc_decoder_init;
54 #ifdef HAVE_FILTER_IA64
55 case LZMA_FILTER_IA64:
56 return &lzma_simple_ia64_decoder_init;
59 #ifdef HAVE_FILTER_ARM
61 return &lzma_simple_arm_decoder_init;
64 #ifdef HAVE_FILTER_ARMTHUMB
65 case LZMA_FILTER_ARMTHUMB:
66 return &lzma_simple_armthumb_decoder_init;
69 #ifdef HAVE_FILTER_SPARC
70 case LZMA_FILTER_SPARC:
71 return &lzma_simple_sparc_decoder_init;
74 #ifdef HAVE_FILTER_DELTA
75 case LZMA_FILTER_DELTA:
76 return &lzma_delta_decoder_init;
79 #ifdef HAVE_FILTER_LZMA
80 case LZMA_FILTER_LZMA:
81 return &lzma_lzma_decoder_init;
84 #ifdef HAVE_FILTER_SUBBLOCK
85 case LZMA_FILTER_SUBBLOCK_HELPER:
86 return &lzma_subblock_decoder_helper_init;
95 lzma_raw_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
96 const lzma_options_filter *options,
97 lzma_vli uncompressed_size, bool allow_implicit)
99 const lzma_ret ret = lzma_raw_coder_init(next, allocator,
100 options, uncompressed_size, &get_function,
101 allow_implicit, false);
104 lzma_next_coder_end(next, allocator);
110 extern LZMA_API lzma_ret
111 lzma_raw_decoder(lzma_stream *strm, const lzma_options_filter *options,
112 lzma_vli uncompressed_size, lzma_bool allow_implicit)
114 return_if_error(lzma_strm_init(strm));
116 strm->internal->supported_actions[LZMA_RUN] = true;
117 strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
119 const lzma_ret ret = lzma_raw_coder_init(&strm->internal->next,
120 strm->allocator, options, uncompressed_size,
121 &get_function, allow_implicit, false);