1 /* lzma_d.c -- 2 3 This file is part of the UPX executable compressor. 4 5 Copyright (C) 2006-2020 Markus Franz Xaver Johannes Oberhumer 6 All Rights Reserved. 7 8 UPX and the UCL library are free software; you can redistribute them 9 and/or modify them under the terms of the GNU General Public License as 10 published by the Free Software Foundation; either version 2 of 11 the License, or (at your option) any later version. 12 13 This program 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 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License 19 along with this program; see the file COPYING. 20 If not, write to the Free Software Foundation, Inc., 21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 22 23 Markus F.X.J. Oberhumer 24 <markus@oberhumer.com> 25 */ 26 27 28 /************************************************************************* 29 // 30 **************************************************************************/ 31 32 #define ACC_LIBC_NAKED 1 33 /*#define ACC_OS_FREESTANDING 1*/ 34 #include "miniacc.h" 35 36 #define UPX_LZMA_COMPAT 1 37 38 #if 0 39 #undef _LZMA_IN_CB 40 #undef _LZMA_OUT_READ 41 #undef _LZMA_PROB32 42 #undef _LZMA_LOC_OPT 43 #endif 44 #if (ACC_ARCH_I086) 45 # define Byte unsigned char 46 # define _7ZIP_BYTE_DEFINED 1 47 #endif 48 #if !defined(_LZMA_UINT32_IS_ULONG) 49 # if defined(__INT_MAX__) && ((__INT_MAX__)+0 == 32767) 50 # define _LZMA_UINT32_IS_ULONG 1 51 # endif 52 #endif 53 #if !defined(_LZMA_NO_SYSTEM_SIZE_T) 54 # define _LZMA_NO_SYSTEM_SIZE_T 1 55 #endif 56 57 #if 0 58 59 #include "C/7zip/Compress/LZMA_C/LzmaDecode.h" 60 #if (ACC_ABI_LP64) 61 #else 62 ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(CLzmaDecoderState) == 16) 63 #endif 64 #include "C/7zip/Compress/LZMA_C/LzmaDecode.c" 65 66 #else 67 68 #define CLzmaDecoderState CLzmaDecoderState_dummy 69 #define LzmaDecodeProperties LzmaDecodeProperties_dummy 70 #define LzmaDecode LzmaDecode_dummy 71 #if (ACC_CC_BORLANDC) 72 #include "LzmaDecode.h" 73 #else 74 #if (WITH_LZMA >= 0x449) 75 # include "C/Compress/Lzma/LzmaDecode.h" 76 #else 77 # include "C/7zip/Compress/LZMA_C/LzmaDecode.h" 78 #endif 79 #endif 80 #undef CLzmaDecoderState 81 #undef LzmaDecodeProperties 82 #undef LzmaDecode 83 typedef struct { 84 struct { unsigned char lc, lp, pb, dummy; } Properties; 85 #ifdef _LZMA_PROB32 86 CProb Probs[8191]; 87 #else 88 CProb Probs[16382]; 89 #endif 90 } CLzmaDecoderState; 91 ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(CLzmaDecoderState) == 32768u) 92 ACC_COMPILE_TIME_ASSERT_HEADER(sizeof(SizeT) >= 4) 93 94 #if (ACC_ARCH_I086) 95 # define char char __huge 96 #elif (ACC_CC_WATCOMC) 97 #else 98 #define CLzmaDecoderState const CLzmaDecoderState 99 #endif 100 int LzmaDecodeProperties(CLzmaProperties *, const unsigned char *, int); 101 int LzmaDecode(CLzmaDecoderState *, const unsigned char *, SizeT, SizeT *, unsigned char *, SizeT, SizeT *); 102 #if (ACC_CC_BORLANDC) 103 #include "LzmaDecode.c" 104 #else 105 #if (WITH_LZMA >= 0x449) 106 # include "C/Compress/Lzma/LzmaDecode.c" 107 #else 108 # include "C/7zip/Compress/LZMA_C/LzmaDecode.c" 109 #endif 110 #endif 111 #undef char 112 #undef CLzmaDecoderState 113 114 #endif 115 116 /* vim:set ts=4 sw=4 et: */ 117