mirror of https://github.com/Cisco-Talos/clamav
git-svn: trunk@3055remotes/push_mirror/metadata
parent
038f17fc74
commit
faaf436a23
@ -0,0 +1,557 @@ |
||||
/*
|
||||
* LZMADecode.c |
||||
*
|
||||
* This file is a part of LZMA compression module for NSIS. |
||||
*
|
||||
* Original LZMA SDK Copyright (C) 1999-2006 Igor Pavlov |
||||
* Modifications Copyright (C) 2003-2007 Amir Szekely <kichik@netvision.net.il> |
||||
*
|
||||
* Licensed under the Common Public License version 1.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
*
|
||||
* Licence details can be found in the file COPYING. |
||||
*
|
||||
* This software is provided 'as-is', without any express or implied |
||||
* warranty. |
||||
*/ |
||||
|
||||
#include <stdlib.h> |
||||
#include "LZMADecode.h" |
||||
|
||||
#define LEAVE { goto saveStateAndReturn; } |
||||
#define NEED_BYTE(c) case c: if (!avail_in) { mode = c; LEAVE; } |
||||
#define NEED_BYTE_ if (!avail_in) LEAVE; |
||||
#define NEXT_BYTE (avail_in--, *next_in++) |
||||
#define NEED_OUT(c) case c: if (!avail_out) { mode = c; LEAVE; } |
||||
#define PUT_BYTE_(b) { *next_out = b; next_out++; avail_out--; } |
||||
#define PUT_BYTE(b) { totalOut++; PUT_BYTE_(b) } |
||||
#define DECODE_BIT(c, x) prob = x; last = c; goto _LZMA_C_RDBD; case c: |
||||
#define DECODE_LEN(c, x) probs = x; last2 = c; goto _LZMA_C_LEND; case c: |
||||
#define DECODE_BIT_TREE(c, x, y) probs = x; numLevels = y; last3 = c; goto _LZMA_C_BTD; case c: |
||||
|
||||
enum { |
||||
/* 0 */ LZMA_C_INIT = 0, |
||||
/* 1 */ LZMA_C_GETDICT, |
||||
/* 2 */ LZMA_C_BLOCK, |
||||
/* 3 */ LZMA_C_RDI, /* RangeDecoderInit */ |
||||
/* 4 */ LZMA_C_RDBD, /* RangeDecoderBitDecode */ |
||||
/* 5 */ LZMA_C_RDBD_IN, /* RangeDecoderBitDecode */ |
||||
/* 6 */ LZMA_C_TYPE, |
||||
/* 7 */ LZMA_C_ISREP, |
||||
/* 8 */ LZMA_C_ISREPG0, |
||||
/* 9 */ LZMA_C_ISREP0LONG, |
||||
/* 10 */ LZMA_C_ISREPG1, |
||||
/* 11 */ LZMA_C_ISREPG2, |
||||
/* 12 */ LZMA_C_NORM, |
||||
/* 13 */ LZMA_C_LITDM1, /* LzmaLiteralDecodeMatch */ |
||||
/* 14 */ LZMA_C_LITDM2, /* LzmaLiteralDecodeMatch */ |
||||
/* 15 */ LZMA_C_LITD, /* LzmaLiteralDecode */ |
||||
/* 16 */ LZMA_C_RDRBTD, /* RangeDecoderReverseBitTreeDecode */ |
||||
/* 17 */ LZMA_C_LEND, /* LzmaLenDecode */ |
||||
/* 18 */ LZMA_C_LEND1, /* LzmaLenDecode */ |
||||
/* 19 */ LZMA_C_LEND2, /* LzmaLenDecode */ |
||||
/* 20 */ LZMA_C_LEND_RES, /* LzmaLenDecode */ |
||||
/* 21 */ LZMA_C_LEND_C1, |
||||
/* 22 */ LZMA_C_LEND_C2, |
||||
/* 23 */ LZMA_C_BTD, /* RangeDecoderBitTreeDecode */ |
||||
/* 24 */ LZMA_C_BTD_LOOP, |
||||
/* 25 */ LZMA_C_BTD_C1, |
||||
/* 26 */ LZMA_C_OUTPUT_1, |
||||
/* 27 */ LZMA_C_OUTPUT_2, |
||||
/* 28 */ LZMA_C_OUTPUT_3 |
||||
}; |
||||
|
||||
#define kNumTopBits 24 |
||||
#define kTopValue ((UInt32)1 << kNumTopBits) |
||||
|
||||
#define kNumBitModelTotalBits 11 |
||||
#define kBitModelTotal (1 << kNumBitModelTotalBits) |
||||
#define kNumMoveBits 5 |
||||
|
||||
#define RC_NORMALIZE(c) if (range < kTopValue) { NEED_BYTE(c); range <<= 8; code = (code << 8) | NEXT_BYTE; } |
||||
|
||||
#define RC_GET_BIT2(c, prob, mi, A0, A1) { \ |
||||
UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; \
|
||||
if (code < bound) \
|
||||
{ A0; range = bound; *prob += (kBitModelTotal - *prob) >> kNumMoveBits; mi <<= 1; } \
|
||||
else \
|
||||
{ A1; range -= bound; code -= bound; *prob -= (*prob) >> kNumMoveBits; mi = (mi + mi) + 1; } \
|
||||
RC_NORMALIZE(c) \
|
||||
} |
||||
|
||||
#define RC_GET_BIT(c, prob, mi) RC_GET_BIT2(c, prob, mi, ; , ;) |
||||
|
||||
#define kNumPosBitsMax 4 |
||||
#define kNumPosStatesMax (1 << kNumPosBitsMax) |
||||
|
||||
#define kLenNumLowBits 3 |
||||
#define kLenNumLowSymbols (1 << kLenNumLowBits) |
||||
#define kLenNumMidBits 3 |
||||
#define kLenNumMidSymbols (1 << kLenNumMidBits) |
||||
#define kLenNumHighBits 8 |
||||
#define kLenNumHighSymbols (1 << kLenNumHighBits) |
||||
|
||||
#define LenChoice 0 |
||||
#define LenChoice2 (LenChoice + 1) |
||||
#define LenLow (LenChoice2 + 1) |
||||
#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) |
||||
#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) |
||||
#define kNumLenProbs (LenHigh + kLenNumHighSymbols) |
||||
|
||||
#define kNumStates 12 |
||||
|
||||
#define kStartPosModelIndex 4 |
||||
#define kEndPosModelIndex 14 |
||||
#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) |
||||
|
||||
#define kNumPosSlotBits 6 |
||||
#define kNumLenToPosStates 4 |
||||
|
||||
#define kNumAlignBits 4 |
||||
#define kAlignTableSize (1 << kNumAlignBits) |
||||
|
||||
#define kMatchMinLen 2 |
||||
|
||||
#define IsMatch 0 |
||||
#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) |
||||
#define IsRepG0 (IsRep + kNumStates) |
||||
#define IsRepG1 (IsRepG0 + kNumStates) |
||||
#define IsRepG2 (IsRepG1 + kNumStates) |
||||
#define IsRep0Long (IsRepG2 + kNumStates) |
||||
#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) |
||||
#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) |
||||
#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) |
||||
#define LenCoder (Align + kAlignTableSize) |
||||
#define RepLenCoder (LenCoder + kNumLenProbs) |
||||
#define Literal (RepLenCoder + kNumLenProbs) |
||||
|
||||
#define LZMA_BASE_SIZE 1846 |
||||
#define LZMA_LIT_SIZE 768 |
||||
|
||||
#if Literal != LZMA_BASE_SIZE |
||||
StopCompilingDueBUG |
||||
#endif |
||||
|
||||
void lzmaInit(lzma_stream *s) |
||||
{ |
||||
/* size of lzma_stream minus the size of the two allocated buffer pointers.
|
||||
we don't want to lose to pointer or else we won't be able to free them. */ |
||||
size_t i = sizeof(lzma_stream) - (sizeof(unsigned char *) * 2); |
||||
while (i--) |
||||
((lzByte *)s)[i] = 0; |
||||
|
||||
s->rep0 = s->rep1 = s->rep2 = s->rep3 = 1; |
||||
s->range = (0xFFFFFFFF); |
||||
} |
||||
|
||||
int lzmaDecode(lzma_stream *s) |
||||
{ |
||||
/* restore decoder state */ |
||||
lzma_stream _s = *s; |
||||
|
||||
#define mode _s.mode |
||||
#define last _s.last |
||||
#define last2 _s.last2 |
||||
#define last3 _s.last3 |
||||
|
||||
#define p (*(CProb **) &_s.dynamicData) |
||||
#define dynamicDataSize _s.dynamicDataSize |
||||
|
||||
#define state _s.state |
||||
#define isPreviousMatch _s.isPreviousMatch |
||||
#define previousByte _s.previousByte |
||||
#define rep0 _s.rep0 |
||||
#define rep1 _s.rep1 |
||||
#define rep2 _s.rep2 |
||||
#define rep3 _s.rep3 |
||||
#define lc _s.lc |
||||
#define len _s.len |
||||
#define totalOut _s.totalOut |
||||
|
||||
#define dictionary _s.dictionary |
||||
#define dictionarySize _s.dictionarySize |
||||
#define dictionaryPos _s.dictionaryPos |
||||
|
||||
#define posStateMask _s.posStateMask |
||||
#define literalPosMask _s.literalPosMask |
||||
|
||||
#define avail_in _s.avail_in |
||||
#define next_in _s.next_in |
||||
#define avail_out _s.avail_out |
||||
#define next_out _s.next_out |
||||
|
||||
#define range _s.range |
||||
#define code _s.code |
||||
|
||||
#define probs _s.probs |
||||
#define prob _s.prob |
||||
|
||||
#define symbol _s.temp2 |
||||
#define bit _s.temp3 |
||||
#define matchBit _s.temp1 |
||||
#define i _s.temp1 |
||||
#define result _s.temp2 |
||||
#define numLevels _s.temp3 |
||||
#define posSlot _s.temp2 |
||||
#define newDictionarySize (*(UInt32*) &_s.temp3) |
||||
|
||||
#define matchByte _s.matchByte |
||||
#define mi _s.mi |
||||
#define posState _s.posState |
||||
|
||||
if (len == -1) |
||||
return LZMA_STREAM_END; |
||||
|
||||
for (;;) switch (mode) |
||||
{ |
||||
case LZMA_C_INIT: |
||||
{ |
||||
lzByte firstByte; |
||||
UInt32 newDynamicDataSize; |
||||
UInt32 numProbs; |
||||
int lp; |
||||
int pb; |
||||
|
||||
NEED_BYTE_; |
||||
|
||||
firstByte = NEXT_BYTE; |
||||
|
||||
if (firstByte > (9*5*5)) |
||||
return LZMA_DATA_ERROR; |
||||
|
||||
pb = firstByte / (9*5); |
||||
firstByte %= (9*5); |
||||
lp = firstByte / 9; |
||||
firstByte %= 9; |
||||
lc = firstByte; |
||||
|
||||
posStateMask = (1 << (pb)) - 1; |
||||
literalPosMask = (1 << (lp)) - 1; |
||||
|
||||
numProbs = Literal + (LZMA_LIT_SIZE << (lc + pb)); |
||||
newDynamicDataSize = numProbs * sizeof(CProb); |
||||
|
||||
if (newDynamicDataSize != dynamicDataSize) |
||||
{ |
||||
if (p) |
||||
lzmafree(p); |
||||
p = lzmaalloc(newDynamicDataSize); |
||||
if (!p) |
||||
return LZMA_NOT_ENOUGH_MEM; |
||||
dynamicDataSize = newDynamicDataSize; |
||||
} |
||||
|
||||
while (numProbs--) |
||||
p[numProbs] = kBitModelTotal >> 1; |
||||
|
||||
for (i = 0, newDictionarySize = 0; i < 4; i++) |
||||
{ |
||||
NEED_BYTE(LZMA_C_GETDICT); |
||||
newDictionarySize |= NEXT_BYTE << (i * 8); |
||||
} |
||||
|
||||
if (newDictionarySize != dictionarySize) |
||||
{ |
||||
dictionarySize = newDictionarySize; |
||||
if (dictionary) |
||||
lzmafree(dictionary); |
||||
dictionary = lzmaalloc(dictionarySize); |
||||
if (!dictionary) |
||||
return LZMA_NOT_ENOUGH_MEM; |
||||
} |
||||
|
||||
dictionary[dictionarySize - 1] = 0; |
||||
|
||||
i = 5; |
||||
while (i--) |
||||
{ |
||||
NEED_BYTE(LZMA_C_RDI); |
||||
code = (code << 8) | NEXT_BYTE; |
||||
} |
||||
} |
||||
case LZMA_C_BLOCK: |
||||
posState = (int)(totalOut & posStateMask); |
||||
DECODE_BIT(LZMA_C_TYPE, p + IsMatch + (state << kNumPosBitsMax) + posState); |
||||
if (bit == 0) |
||||
{ |
||||
probs = p + Literal + (LZMA_LIT_SIZE * |
||||
(((totalOut & literalPosMask) << lc) + (previousByte >> (8 - lc)))); |
||||
|
||||
if (state < 4) state = 0; |
||||
else if (state < 10) state -= 3; |
||||
else state -= 6; |
||||
if (isPreviousMatch) |
||||
{ |
||||
UInt32 pos = dictionaryPos - rep0; |
||||
if (pos >= dictionarySize) |
||||
pos += dictionarySize; |
||||
matchByte = dictionary[pos]; |
||||
{ |
||||
symbol = 1; |
||||
do |
||||
{ |
||||
matchBit = (matchByte >> 7) & 1; |
||||
matchByte <<= 1; |
||||
{ |
||||
prob = probs + ((1 + matchBit) << 8) + symbol; |
||||
RC_GET_BIT2(LZMA_C_LITDM1, prob, symbol, bit = 0, bit = 1) |
||||
} |
||||
if (matchBit != bit) |
||||
{ |
||||
while (symbol < 0x100) |
||||
{ |
||||
prob = probs + symbol; |
||||
RC_GET_BIT(LZMA_C_LITDM2, prob, symbol) |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
while (symbol < 0x100); |
||||
previousByte = symbol; |
||||
} |
||||
isPreviousMatch = 0; |
||||
} |
||||
else |
||||
{ |
||||
symbol = 1; |
||||
do |
||||
{ |
||||
prob = probs + symbol; |
||||
RC_GET_BIT(LZMA_C_LITD, prob, symbol) |
||||
} |
||||
while (symbol < 0x100); |
||||
previousByte = symbol; |
||||
} |
||||
NEED_OUT(LZMA_C_OUTPUT_1); |
||||
PUT_BYTE(previousByte); |
||||
dictionary[dictionaryPos] = previousByte; |
||||
dictionaryPos = (dictionaryPos + 1) % dictionarySize; |
||||
} |
||||
/* bit == 1 */ |
||||
else |
||||
{ |
||||
isPreviousMatch = 1; |
||||
DECODE_BIT(LZMA_C_ISREP, p + IsRep + state); |
||||
if (bit == 1) |
||||
{ |
||||
DECODE_BIT(LZMA_C_ISREPG0, p + IsRepG0 + state); |
||||
if (bit == 0) |
||||
{ |
||||
DECODE_BIT(LZMA_C_ISREP0LONG, p + IsRep0Long + (state << kNumPosBitsMax) + posState); |
||||
if (bit == 0) |
||||
{ |
||||
UInt32 pos; |
||||
if (totalOut == 0) |
||||
return LZMA_DATA_ERROR; |
||||
state = state < 7 ? 9 : 11; |
||||
NEED_OUT(LZMA_C_OUTPUT_2); |
||||
pos = dictionaryPos - rep0; |
||||
if (pos >= dictionarySize) |
||||
pos += dictionarySize; |
||||
previousByte = dictionary[pos]; |
||||
dictionary[dictionaryPos] = previousByte; |
||||
dictionaryPos = (dictionaryPos + 1) % dictionarySize; |
||||
PUT_BYTE(previousByte); |
||||
mode = LZMA_C_BLOCK; |
||||
break; |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
UInt32 distance; |
||||
DECODE_BIT(LZMA_C_ISREPG1, p + IsRepG1 + state); |
||||
if (bit == 0) |
||||
{ |
||||
distance = rep1; |
||||
} |
||||
else |
||||
{ |
||||
DECODE_BIT(LZMA_C_ISREPG2, p + IsRepG2 + state); |
||||
if (bit == 0) |
||||
distance = rep2; |
||||
else |
||||
{ |
||||
distance = rep3; |
||||
rep3 = rep2; |
||||
} |
||||
rep2 = rep1; |
||||
} |
||||
rep1 = rep0; |
||||
rep0 = distance; |
||||
} |
||||
DECODE_LEN(LZMA_C_LEND_C1, p + RepLenCoder); |
||||
state = state < 7 ? 8 : 11; |
||||
} |
||||
else |
||||
{ |
||||
rep3 = rep2; |
||||
rep2 = rep1; |
||||
rep1 = rep0; |
||||
state = state < 7 ? 7 : 10; |
||||
DECODE_LEN(LZMA_C_LEND_C2, p + LenCoder); |
||||
DECODE_BIT_TREE( |
||||
LZMA_C_BTD_C1, |
||||
p + PosSlot + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits), |
||||
kNumPosSlotBits |
||||
); |
||||
if (posSlot >= kStartPosModelIndex) |
||||
{ |
||||
int numDirectBits = ((posSlot >> 1) - 1); |
||||
rep0 = ((2 | ((UInt32)posSlot & 1)) << numDirectBits); |
||||
if (posSlot < kEndPosModelIndex) |
||||
{ |
||||
probs = p + SpecPos + rep0 - posSlot - 1; |
||||
numLevels = numDirectBits; |
||||
} |
||||
else |
||||
{ |
||||
int numTotalBits = numDirectBits - kNumAlignBits; |
||||
result = 0; |
||||
for (i = numTotalBits; i > 0; i--) |
||||
{ |
||||
/* UInt32 t; */ |
||||
range >>= 1; |
||||
|
||||
result <<= 1; |
||||
if (code >= range) |
||||
{ |
||||
code -= range; |
||||
result |= 1; |
||||
} |
||||
/*
|
||||
t = (code - range) >> 31; |
||||
t &= 1; |
||||
code -= range & (t - 1); |
||||
result = (result + result) | (1 - t); |
||||
*/ |
||||
RC_NORMALIZE(LZMA_C_NORM) |
||||
} |
||||
rep0 += result << kNumAlignBits; |
||||
probs = p + Align; |
||||
numLevels = kNumAlignBits; |
||||
} |
||||
mi = 1; |
||||
symbol = 0; |
||||
for(i = 0; i < numLevels; i++) |
||||
{ |
||||
prob = probs + mi; |
||||
RC_GET_BIT2(LZMA_C_RDRBTD, prob, mi, ; , symbol |= (1 << i)); |
||||
} |
||||
rep0 += symbol; |
||||
} |
||||
else |
||||
rep0 = posSlot; |
||||
rep0++; |
||||
} |
||||
if (rep0 == (UInt32)(0)) |
||||
{ |
||||
len = -1; |
||||
LEAVE; |
||||
} |
||||
if (rep0 > totalOut) |
||||
{ |
||||
return LZMA_DATA_ERROR; |
||||
} |
||||
len += kMatchMinLen; |
||||
totalOut += len; |
||||
do |
||||
{ |
||||
UInt32 pos; |
||||
NEED_OUT(LZMA_C_OUTPUT_3); |
||||
pos = dictionaryPos - rep0; |
||||
if (pos >= dictionarySize) |
||||
pos += dictionarySize; |
||||
previousByte = dictionary[pos]; |
||||
dictionary[dictionaryPos] = previousByte; |
||||
dictionaryPos = (dictionaryPos + 1) % dictionarySize; |
||||
PUT_BYTE_(previousByte); |
||||
len--; |
||||
} |
||||
while(len > 0); |
||||
} |
||||
mode = LZMA_C_BLOCK; |
||||
break; |
||||
case LZMA_C_RDBD: |
||||
_LZMA_C_RDBD: |
||||
{ |
||||
UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; |
||||
if (code < bound) |
||||
{ |
||||
range = bound; |
||||
*prob += (kBitModelTotal - *prob) >> kNumMoveBits; |
||||
bit = 0; |
||||
} |
||||
else |
||||
{ |
||||
range -= bound; |
||||
code -= bound; |
||||
*prob -= (*prob) >> kNumMoveBits; |
||||
bit = 1; |
||||
} |
||||
RC_NORMALIZE(LZMA_C_RDBD_IN); |
||||
} |
||||
mode = last; |
||||
break; |
||||
case LZMA_C_LEND: |
||||
_LZMA_C_LEND: |
||||
DECODE_BIT(LZMA_C_LEND1, probs + LenChoice); |
||||
if (bit == 0) |
||||
{ |
||||
len = 0; |
||||
probs += LenLow + (posState << kLenNumLowBits); |
||||
numLevels = kLenNumLowBits; |
||||
} |
||||
else { |
||||
DECODE_BIT(LZMA_C_LEND2, probs + LenChoice2); |
||||
if (bit == 0) |
||||
{ |
||||
len = kLenNumLowSymbols; |
||||
probs += + LenMid + (posState << kLenNumMidBits); |
||||
numLevels = kLenNumMidBits; |
||||
} |
||||
else |
||||
{ |
||||
len = kLenNumLowSymbols + kLenNumMidSymbols; |
||||
probs += LenHigh; |
||||
numLevels = kLenNumHighBits; |
||||
} |
||||
} |
||||
|
||||
last3 = LZMA_C_LEND_RES; |
||||
case LZMA_C_BTD: |
||||
_LZMA_C_BTD: |
||||
mi = 1; |
||||
for(i = numLevels; i > 0; i--) |
||||
{ |
||||
prob = probs + mi; |
||||
RC_GET_BIT(LZMA_C_BTD_LOOP, prob, mi) |
||||
} |
||||
result = mi - (1 << numLevels); |
||||
mode = last3; |
||||
break; |
||||
case LZMA_C_LEND_RES: |
||||
len += result; |
||||
mode = last2; |
||||
break; |
||||
default: |
||||
return LZMA_DATA_ERROR; |
||||
} |
||||
|
||||
saveStateAndReturn: |
||||
|
||||
/* save decoder state */ |
||||
*s = _s; |
||||
|
||||
return LZMA_OK; |
||||
} |
||||
|
||||
|
||||
/* aCaB */ |
||||
void lzmaShutdown(lzma_stream *s) { |
||||
lzma_stream _s = *s; |
||||
if (p) lzmafree(p); |
||||
if (dictionary) lzmafree(dictionary); |
||||
p = NULL; |
||||
dictionary = NULL; |
||||
*s = _s; |
||||
} |
||||
@ -0,0 +1,126 @@ |
||||
/*
|
||||
* LZMADecode.c |
||||
*
|
||||
* This file is a part of LZMA compression module for NSIS. |
||||
*
|
||||
* Original LZMA SDK Copyright (C) 1999-2006 Igor Pavlov |
||||
* Modifications Copyright (C) 2003-2007 Amir Szekely <kichik@netvision.net.il> |
||||
*
|
||||
* Licensed under the Common Public License version 1.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
*
|
||||
* Licence details can be found in the file COPYING. |
||||
*
|
||||
* This software is provided 'as-is', without any express or implied |
||||
* warranty. |
||||
*/ |
||||
|
||||
#ifndef __LZMADECODE_H |
||||
#define __LZMADECODE_H |
||||
|
||||
/* #define _LZMA_PROB32 */ |
||||
/* It can increase speed on some 32-bit CPUs,
|
||||
but memory usage will be doubled in that case */ |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#include "others.h" |
||||
|
||||
#ifndef lzmaalloc |
||||
#define lzmaalloc cli_malloc |
||||
#endif |
||||
|
||||
#ifndef lzmafree |
||||
#define lzmafree free |
||||
#endif |
||||
|
||||
#ifndef LZMACALL |
||||
# define LZMACALL |
||||
#endif |
||||
|
||||
#ifndef UInt32 |
||||
#ifdef _LZMA_UINT32_IS_ULONG |
||||
#define UInt32 unsigned long |
||||
#else |
||||
#define UInt32 unsigned int |
||||
#endif |
||||
#endif |
||||
|
||||
#ifdef _LZMA_PROB32 |
||||
#define CProb UInt32 |
||||
#else |
||||
#define CProb unsigned short |
||||
#endif |
||||
|
||||
typedef unsigned char lzByte; |
||||
|
||||
#define LZMA_STREAM_END 1 |
||||
#define LZMA_OK 0 |
||||
#define LZMA_DATA_ERROR -1 |
||||
/* we don't really care what the problem is... */ |
||||
/* #define LZMA_RESULT_NOT_ENOUGH_MEM -2 */ |
||||
#define LZMA_NOT_ENOUGH_MEM -1 |
||||
|
||||
typedef struct |
||||
{ |
||||
/* mode control */ |
||||
int mode; |
||||
int last; |
||||
int last2; |
||||
int last3; |
||||
|
||||
/* properties */ |
||||
UInt32 dynamicDataSize; |
||||
UInt32 dictionarySize; |
||||
|
||||
/* io */ |
||||
lzByte *next_in; /* next input byte */ |
||||
UInt32 avail_in; /* number of bytes available at next_in */ |
||||
|
||||
lzByte *next_out; /* next output byte should be put there */ |
||||
UInt32 avail_out; /* remaining free space at next_out */ |
||||
|
||||
UInt32 totalOut; /* total output - not always correct when lzmaDecode returns */ |
||||
|
||||
/* saved state */ |
||||
lzByte previousByte; |
||||
lzByte matchByte; |
||||
CProb *probs; |
||||
CProb *prob; |
||||
int mi; |
||||
int posState; |
||||
int temp1; |
||||
int temp2; |
||||
int temp3; |
||||
int lc; |
||||
int state; |
||||
int isPreviousMatch; |
||||
int len; |
||||
UInt32 rep0; |
||||
UInt32 rep1; |
||||
UInt32 rep2; |
||||
UInt32 rep3; |
||||
UInt32 posStateMask; |
||||
UInt32 literalPosMask; |
||||
UInt32 dictionaryPos; |
||||
|
||||
/* range coder */ |
||||
UInt32 range; |
||||
UInt32 code; |
||||
|
||||
/* allocated buffers */ |
||||
lzByte *dictionary; |
||||
lzByte *dynamicData; |
||||
} lzma_stream; |
||||
|
||||
void LZMACALL lzmaInit(lzma_stream *); |
||||
int LZMACALL lzmaDecode(lzma_stream *); |
||||
void LZMACALL lzmaShutdown(lzma_stream *); /* aCaB */ |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif |
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,497 @@ |
||||
|
||||
/*-------------------------------------------------------------*/ |
||||
/*--- Private header file for the library. ---*/ |
||||
/*--- bzlib_private.h ---*/ |
||||
/*-------------------------------------------------------------*/ |
||||
|
||||
/* ------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for |
||||
lossless, block-sorting data compression. |
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006 |
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org> |
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||
README file. |
||||
|
||||
This program is released under the terms of the license contained |
||||
in the file LICENSE. |
||||
------------------------------------------------------------------ */ |
||||
|
||||
|
||||
#ifndef _BZLIB_PRIVATE_H |
||||
#define _BZLIB_PRIVATE_H |
||||
|
||||
#include <stdlib.h> |
||||
|
||||
#ifndef BZ_NO_STDIO |
||||
#include <stdio.h> |
||||
#include <ctype.h> |
||||
#include <string.h> |
||||
#endif |
||||
|
||||
#include "nsis_bzlib.h" |
||||
|
||||
|
||||
|
||||
/*-- General stuff. --*/ |
||||
|
||||
#define BZ_VERSION "1.0.4, 20-Dec-2006" |
||||
|
||||
typedef char Char; |
||||
typedef unsigned char Bool; |
||||
typedef unsigned char UChar; |
||||
typedef int Int32; |
||||
typedef unsigned int UInt32; |
||||
typedef short Int16; |
||||
typedef unsigned short UInt16; |
||||
|
||||
#define True ((Bool)1) |
||||
#define False ((Bool)0) |
||||
|
||||
#ifndef __GNUC__ |
||||
#define __inline__ /* */ |
||||
#endif |
||||
|
||||
/* aCaB */ |
||||
/* #ifndef BZ_NO_STDIO */ |
||||
|
||||
/* extern void BZ2_bz__AssertH__fail ( int errcode ); */ |
||||
/* #define AssertH(cond,errcode) \ */ |
||||
/* { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } */ |
||||
|
||||
/* #if BZ_DEBUG */ |
||||
/* #define AssertD(cond,msg) \ */ |
||||
/* { if (!(cond)) { \ */ |
||||
/* fprintf ( stderr, \ */ |
||||
/* "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ */ |
||||
/* exit(1); \ */ |
||||
/* }} */ |
||||
/* #else */ |
||||
/* #define AssertD(cond,msg) /\* *\/ */ |
||||
/* #endif */ |
||||
|
||||
/* #define VPrintf0(zf) \ */ |
||||
/* fprintf(stderr,zf) */ |
||||
/* #define VPrintf1(zf,za1) \ */ |
||||
/* fprintf(stderr,zf,za1) */ |
||||
/* #define VPrintf2(zf,za1,za2) \ */ |
||||
/* fprintf(stderr,zf,za1,za2) */ |
||||
/* #define VPrintf3(zf,za1,za2,za3) \ */ |
||||
/* fprintf(stderr,zf,za1,za2,za3) */ |
||||
/* #define VPrintf4(zf,za1,za2,za3,za4) \ */ |
||||
/* fprintf(stderr,zf,za1,za2,za3,za4) */ |
||||
/* #define VPrintf5(zf,za1,za2,za3,za4,za5) \ */ |
||||
/* fprintf(stderr,zf,za1,za2,za3,za4,za5) */ |
||||
|
||||
/* #else */ |
||||
|
||||
/* extern void bz_internal_error ( int errcode ); */ |
||||
/* #define AssertH(cond,errcode) \ */ |
||||
/* { if (!(cond)) bz_internal_error ( errcode ); } */ |
||||
/* #define AssertD(cond,msg) do { } while (0) */ |
||||
#define VPrintf0(zf) do { } while (0) |
||||
#define VPrintf1(zf,za1) do { } while (0) |
||||
#define VPrintf2(zf,za1,za2) do { } while (0) |
||||
#define VPrintf3(zf,za1,za2,za3) do { } while (0) |
||||
#define VPrintf4(zf,za1,za2,za3,za4) do { } while (0) |
||||
#define VPrintf5(zf,za1,za2,za3,za4,za5) do { } while (0) |
||||
|
||||
/* #endif */ |
||||
|
||||
#define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) |
||||
#define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) |
||||
|
||||
|
||||
/*-- Header bytes. --*/ |
||||
|
||||
/* #define BZ_HDR_B 0x42 /\* 'B' *\/ */ |
||||
/* #define BZ_HDR_Z 0x5a /\* 'Z' *\/ */ |
||||
/* #define BZ_HDR_h 0x68 /\* 'h' *\/ */ |
||||
/* #define BZ_HDR_0 0x30 /\* '0' *\/ */ |
||||
|
||||
/*-- Constants for the back end. --*/ |
||||
|
||||
#define BZ_MAX_ALPHA_SIZE 258 |
||||
#define BZ_MAX_CODE_LEN 23 |
||||
|
||||
#define BZ_RUNA 0 |
||||
#define BZ_RUNB 1 |
||||
|
||||
#define BZ_N_GROUPS 6 |
||||
#define BZ_G_SIZE 50 |
||||
#define BZ_N_ITERS 4 |
||||
|
||||
#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE)) |
||||
|
||||
|
||||
|
||||
/*-- Stuff for randomising repetitive blocks. --*/ |
||||
/* aCaB */ |
||||
/* extern Int32 BZ2_rNums[512]; */ |
||||
|
||||
#define BZ_RAND_DECLS \ |
||||
Int32 rNToGo; \
|
||||
Int32 rTPos \
|
||||
|
||||
#define BZ_RAND_INIT_MASK \ |
||||
s->rNToGo = 0; \
|
||||
s->rTPos = 0 \
|
||||
|
||||
#define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0) |
||||
|
||||
#define BZ_RAND_UPD_MASK \ |
||||
if (s->rNToGo == 0) { \
|
||||
s->rNToGo = BZ2_rNums[s->rTPos]; \
|
||||
s->rTPos++; \
|
||||
if (s->rTPos == 512) s->rTPos = 0; \
|
||||
} \
|
||||
s->rNToGo--; |
||||
/**/ |
||||
|
||||
/*-- Stuff for doing CRCs. --*/ |
||||
/* aCaB
|
||||
extern UInt32 BZ2_crc32Table[256]; |
||||
|
||||
#define BZ_INITIALISE_CRC(crcVar) \ |
||||
{ \
|
||||
crcVar = 0xffffffffL; \
|
||||
} |
||||
|
||||
#define BZ_FINALISE_CRC(crcVar) \ |
||||
{ \
|
||||
crcVar = ~(crcVar); \
|
||||
} |
||||
|
||||
#define BZ_UPDATE_CRC(crcVar,cha) \ |
||||
{ \
|
||||
crcVar = (crcVar << 8) ^ \
|
||||
BZ2_crc32Table[(crcVar >> 24) ^ \
|
||||
((UChar)cha)]; \
|
||||
} |
||||
*/ |
||||
|
||||
/*-- States and modes for compression. --*/ |
||||
|
||||
#define BZ_M_IDLE 1 |
||||
#define BZ_M_RUNNING 2 |
||||
#define BZ_M_FLUSHING 3 |
||||
#define BZ_M_FINISHING 4 |
||||
|
||||
#define BZ_S_OUTPUT 1 |
||||
#define BZ_S_INPUT 2 |
||||
|
||||
#define BZ_N_RADIX 2 |
||||
#define BZ_N_QSORT 12 |
||||
#define BZ_N_SHELL 18 |
||||
#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) |
||||
|
||||
|
||||
|
||||
|
||||
/*-- Structure holding all the compression-side stuff. --*/ |
||||
|
||||
typedef |
||||
struct { |
||||
/* pointer back to the struct nsis_bzstream */ |
||||
nsis_bzstream* strm; |
||||
|
||||
/* mode this stream is in, and whether inputting */ |
||||
/* or outputting data */ |
||||
Int32 mode; |
||||
Int32 state; |
||||
|
||||
/* remembers avail_in when flush/finish requested */ |
||||
UInt32 avail_in_expect; |
||||
|
||||
/* for doing the block sorting */ |
||||
UInt32* arr1; |
||||
UInt32* arr2; |
||||
UInt32* ftab; |
||||
Int32 origPtr; |
||||
|
||||
/* aliases for arr1 and arr2 */ |
||||
UInt32* ptr; |
||||
UChar* block; |
||||
UInt16* mtfv; |
||||
UChar* zbits; |
||||
|
||||
/* for deciding when to use the fallback sorting algorithm */ |
||||
Int32 workFactor; |
||||
|
||||
/* run-length-encoding of the input */ |
||||
UInt32 state_in_ch; |
||||
Int32 state_in_len; |
||||
BZ_RAND_DECLS; |
||||
|
||||
/* input and output limits and current posns */ |
||||
Int32 nblock; |
||||
Int32 nblockMAX; |
||||
Int32 numZ; |
||||
Int32 state_out_pos; |
||||
|
||||
/* map of bytes used in block */ |
||||
Int32 nInUse; |
||||
Bool inUse[256]; |
||||
UChar unseqToSeq[256]; |
||||
|
||||
/* the buffer for bit stream creation */ |
||||
UInt32 bsBuff; |
||||
Int32 bsLive; |
||||
|
||||
/* block and combined CRCs */ |
||||
UInt32 blockCRC; |
||||
UInt32 combinedCRC; |
||||
|
||||
/* misc administratium */ |
||||
Int32 verbosity; |
||||
Int32 blockNo; |
||||
Int32 blockSize100k; |
||||
|
||||
/* stuff for coding the MTF values */ |
||||
Int32 nMTF; |
||||
Int32 mtfFreq [BZ_MAX_ALPHA_SIZE]; |
||||
UChar selector [BZ_MAX_SELECTORS]; |
||||
UChar selectorMtf[BZ_MAX_SELECTORS]; |
||||
|
||||
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
||||
Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
||||
Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
||||
/* second dimension: only 3 needed; 4 makes index calculations faster */ |
||||
UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4]; |
||||
|
||||
} |
||||
EState; |
||||
|
||||
|
||||
|
||||
/*-- externs for compression. --*/ |
||||
/* aCaB
|
||||
extern void
|
||||
BZ2_blockSort ( EState* ); |
||||
|
||||
extern void
|
||||
BZ2_compressBlock ( EState*, Bool ); |
||||
|
||||
extern void
|
||||
BZ2_bsInitWrite ( EState* ); |
||||
|
||||
extern void
|
||||
BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); |
||||
|
||||
extern void
|
||||
BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); |
||||
*/ |
||||
|
||||
|
||||
/*-- states for decompression. --*/ |
||||
|
||||
#define BZ_X_IDLE 1 |
||||
#define BZ_X_OUTPUT 2 |
||||
|
||||
#define BZ_X_MAGIC_1 10 |
||||
#define BZ_X_MAGIC_2 11 |
||||
#define BZ_X_MAGIC_3 12 |
||||
#define BZ_X_MAGIC_4 13 |
||||
#define BZ_X_BLKHDR_1 14 |
||||
#define BZ_X_BLKHDR_2 15 |
||||
#define BZ_X_BLKHDR_3 16 |
||||
#define BZ_X_BLKHDR_4 17 |
||||
#define BZ_X_BLKHDR_5 18 |
||||
#define BZ_X_BLKHDR_6 19 |
||||
#define BZ_X_BCRC_1 20 |
||||
#define BZ_X_BCRC_2 21 |
||||
#define BZ_X_BCRC_3 22 |
||||
#define BZ_X_BCRC_4 23 |
||||
#define BZ_X_RANDBIT 24 |
||||
#define BZ_X_ORIGPTR_1 25 |
||||
#define BZ_X_ORIGPTR_2 26 |
||||
#define BZ_X_ORIGPTR_3 27 |
||||
#define BZ_X_MAPPING_1 28 |
||||
#define BZ_X_MAPPING_2 29 |
||||
#define BZ_X_SELECTOR_1 30 |
||||
#define BZ_X_SELECTOR_2 31 |
||||
#define BZ_X_SELECTOR_3 32 |
||||
#define BZ_X_CODING_1 33 |
||||
#define BZ_X_CODING_2 34 |
||||
#define BZ_X_CODING_3 35 |
||||
#define BZ_X_MTF_1 36 |
||||
#define BZ_X_MTF_2 37 |
||||
#define BZ_X_MTF_3 38 |
||||
#define BZ_X_MTF_4 39 |
||||
#define BZ_X_MTF_5 40 |
||||
#define BZ_X_MTF_6 41 |
||||
#define BZ_X_ENDHDR_2 42 |
||||
#define BZ_X_ENDHDR_3 43 |
||||
#define BZ_X_ENDHDR_4 44 |
||||
#define BZ_X_ENDHDR_5 45 |
||||
#define BZ_X_ENDHDR_6 46 |
||||
#define BZ_X_CCRC_1 47 |
||||
#define BZ_X_CCRC_2 48 |
||||
#define BZ_X_CCRC_3 49 |
||||
#define BZ_X_CCRC_4 50 |
||||
|
||||
|
||||
|
||||
/*-- Constants for the fast MTF decoder. --*/ |
||||
|
||||
#define MTFA_SIZE 4096 |
||||
#define MTFL_SIZE 16 |
||||
|
||||
|
||||
|
||||
/*-- Structure holding all the decompression-side stuff. --*/ |
||||
|
||||
typedef |
||||
struct { |
||||
/* pointer back to the struct nsis_bzstream */ |
||||
nsis_bzstream* strm; |
||||
|
||||
/* state indicator for this stream */ |
||||
Int32 state; |
||||
|
||||
/* for doing the final run-length decoding */ |
||||
UChar state_out_ch; |
||||
Int32 state_out_len; |
||||
Bool blockRandomised; |
||||
BZ_RAND_DECLS; |
||||
|
||||
/* the buffer for bit stream reading */ |
||||
UInt32 bsBuff; |
||||
Int32 bsLive; |
||||
|
||||
/* misc administratium */ |
||||
Int32 blockSize100k; |
||||
Bool smallDecompress; |
||||
Int32 currBlockNo; |
||||
Int32 verbosity; |
||||
|
||||
/* for undoing the Burrows-Wheeler transform */ |
||||
Int32 origPtr; |
||||
UInt32 tPos; |
||||
Int32 k0; |
||||
Int32 unzftab[256]; |
||||
Int32 nblock_used; |
||||
Int32 cftab[257]; |
||||
Int32 cftabCopy[257]; |
||||
|
||||
/* for undoing the Burrows-Wheeler transform (FAST) */ |
||||
UInt32 *tt; |
||||
|
||||
/* for undoing the Burrows-Wheeler transform (SMALL) */ |
||||
UInt16 *ll16; |
||||
UChar *ll4; |
||||
|
||||
/* stored and calculated CRCs */ |
||||
UInt32 storedBlockCRC; |
||||
UInt32 storedCombinedCRC; |
||||
UInt32 calculatedBlockCRC; |
||||
UInt32 calculatedCombinedCRC; |
||||
|
||||
/* map of bytes used in block */ |
||||
Int32 nInUse; |
||||
Bool inUse[256]; |
||||
Bool inUse16[16]; |
||||
UChar seqToUnseq[256]; |
||||
|
||||
/* for decoding the MTF values */ |
||||
UChar mtfa [MTFA_SIZE]; |
||||
Int32 mtfbase[256 / MTFL_SIZE]; |
||||
UChar selector [BZ_MAX_SELECTORS]; |
||||
UChar selectorMtf[BZ_MAX_SELECTORS]; |
||||
UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
||||
|
||||
Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
||||
Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
||||
Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; |
||||
Int32 minLens[BZ_N_GROUPS]; |
||||
|
||||
/* save area for scalars in the main decompress code */ |
||||
Int32 save_i; |
||||
Int32 save_j; |
||||
Int32 save_t; |
||||
Int32 save_alphaSize; |
||||
Int32 save_nGroups; |
||||
Int32 save_nSelectors; |
||||
Int32 save_EOB; |
||||
Int32 save_groupNo; |
||||
Int32 save_groupPos; |
||||
Int32 save_nextSym; |
||||
Int32 save_nblockMAX; |
||||
Int32 save_nblock; |
||||
Int32 save_es; |
||||
Int32 save_N; |
||||
Int32 save_curr; |
||||
Int32 save_zt; |
||||
Int32 save_zn;
|
||||
Int32 save_zvec; |
||||
Int32 save_zj; |
||||
Int32 save_gSel; |
||||
Int32 save_gMinlen; |
||||
Int32* save_gLimit; |
||||
Int32* save_gBase; |
||||
Int32* save_gPerm; |
||||
|
||||
} |
||||
DState; |
||||
|
||||
|
||||
|
||||
/*-- Macros for decompression. --*/ |
||||
|
||||
#define BZ_GET_FAST(cccc) \ |
||||
s->tPos = s->tt[s->tPos]; \
|
||||
cccc = (UChar)(s->tPos & 0xff); \
|
||||
s->tPos >>= 8; |
||||
|
||||
#define BZ_GET_FAST_C(cccc) \ |
||||
c_tPos = c_tt[c_tPos]; \
|
||||
cccc = (UChar)(c_tPos & 0xff); \
|
||||
c_tPos >>= 8; |
||||
|
||||
#define SET_LL4(i,n) \ |
||||
{ if (((i) & 0x1) == 0) \
|
||||
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \
|
||||
s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \
|
||||
} |
||||
|
||||
#define GET_LL4(i) \ |
||||
((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF) |
||||
|
||||
#define SET_LL(i,n) \ |
||||
{ s->ll16[i] = (UInt16)(n & 0x0000ffff); \
|
||||
SET_LL4(i, n >> 16); \
|
||||
} |
||||
|
||||
#define GET_LL(i) \ |
||||
(((UInt32)s->ll16[i]) | (GET_LL4(i) << 16)) |
||||
|
||||
#define BZ_GET_SMALL(cccc) \ |
||||
cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \
|
||||
s->tPos = GET_LL(s->tPos); |
||||
|
||||
|
||||
/*-- externs for decompression. --*/ |
||||
|
||||
extern Int32 BZ2_indexIntoF ( Int32, Int32* ); |
||||
|
||||
/* extern Int32 */ |
||||
/* BZ2_decompress ( DState* ); */ |
||||
|
||||
extern void BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); |
||||
|
||||
#endif |
||||
|
||||
|
||||
/*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ |
||||
|
||||
#ifdef BZ_NO_STDIO |
||||
#ifndef NULL |
||||
#define NULL 0 |
||||
#endif |
||||
#endif |
||||
|
||||
|
||||
/*-------------------------------------------------------------*/ |
||||
/*--- end bzlib_private.h ---*/ |
||||
/*-------------------------------------------------------------*/ |
||||
@ -0,0 +1,697 @@ |
||||
#include "nsis_zutil.h" |
||||
#include <string.h> |
||||
|
||||
#ifndef min |
||||
# define min(x,y) ((x<y)?x:y) |
||||
#endif |
||||
|
||||
/* defines for inflate input/output */ |
||||
/* update pointers and return */ |
||||
#define UPDBITS {s->bitb=b;s->bitk=k;} |
||||
#define UPDIN {z->avail_in=n;z->next_in=p;} |
||||
#define UPDOUT {s->write=q;} |
||||
#define UPDATE {UPDBITS UPDIN UPDOUT} |
||||
#define LEAVE(r) {UPDATE inflate_flush(z); return r;} |
||||
|
||||
/* get bytes and bits */ |
||||
#define LOADIN {p=z->next_in;n=z->avail_in;b=s->bitb;k=s->bitk;} |
||||
|
||||
|
||||
#define NEEDBYTE {if(!n)LEAVE(Z_OK)} |
||||
#define NEXTBYTE (n--,*p++) |
||||
#define NEEDBITS(j) {while(k<(j)){NEEDBYTE;b|=((uLong)NEXTBYTE)<<k;k+=8;}} |
||||
|
||||
#define DUMPBITS(j) {b>>=(j);k-=(j);} |
||||
/* output bytes */ |
||||
#define WAVAIL (uInt)(q<s->read?s->read-q-1:s->end-q) |
||||
#define LOADOUT {q=s->write;m=(uInt)WAVAIL;} |
||||
#define WRAP {if(q==s->end&&s->read!=s->window){q=s->window;m=(uInt)WAVAIL;}} |
||||
#define FLUSH {UPDOUT inflate_flush(z); LOADOUT} |
||||
#define NEEDOUT {if(m==0){WRAP if(m==0){FLUSH WRAP if(m==0) LEAVE(Z_OK)}}} |
||||
#define OUTBYTE(a) {*q++=(Byte)(a);m--;} |
||||
/* load local pointers */ |
||||
#define LOAD {LOADIN LOADOUT} |
||||
|
||||
#define LAST (s->last == DRY) |
||||
|
||||
#define FIXEDH 544 /* number of hufts used by fixed tables */ |
||||
|
||||
|
||||
|
||||
typedef struct inflate_blocks_state FAR inflate_blocks_statef; |
||||
#define exop word.what.Exop |
||||
#define bits word.what.Bits |
||||
|
||||
/* And'ing with mask[n] masks the lower n bits */ |
||||
local unsigned short inflate_mask[17] = { |
||||
0x0000, |
||||
0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, |
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff |
||||
}; /* use to reduce .data #define INFLATE_MASK(x, n) (x & (~((unsigned short) 0xFFFF << n))) */ |
||||
local const char border[] = { /* Order of the bit length code lengths */ |
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; |
||||
|
||||
/* Tables for deflate from PKZIP's appnote.txt. */ |
||||
local const unsigned short cplens[31] = { /* Copy lengths for literal codes 257..285 */ |
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, |
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; |
||||
/* see note #13 above about 258 */ |
||||
local const unsigned short cplext[31] = { /* Extra bits for literal codes 257..285 */ |
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, |
||||
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 112, 112}; /* 112==invalid */ |
||||
local const unsigned short cpdist[30] = { /* Copy offsets for distance codes 0..29 */ |
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, |
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, |
||||
8193, 12289, 16385, 24577}; |
||||
local const unsigned short cpdext[30] = { /* Extra bits for distance codes */ |
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, |
||||
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, |
||||
12, 12, 13, 13}; |
||||
|
||||
/* build fixed tables only once--keep them here */ |
||||
local char fixed_built = 0; |
||||
local inflate_huft fixed_mem[FIXEDH]; |
||||
local uInt fixed_bl=9; |
||||
local uInt fixed_bd=5; |
||||
local inflate_huft *fixed_tl; |
||||
local inflate_huft *fixed_td; |
||||
|
||||
/* copy as much as possible from the sliding window to the output area */ |
||||
local void ZEXPORT inflate_flush(nsis_z_streamp z) |
||||
{ |
||||
inflate_blocks_statef *s = &z->blocks; |
||||
uInt n; |
||||
Bytef *q; |
||||
|
||||
/* local copies of source and destination pointers */ |
||||
q = s->read; |
||||
|
||||
again: |
||||
/* compute number of bytes to copy as far as end of window */ |
||||
n = (uInt)((q <= s->write ? s->write : s->end) - q); |
||||
n = min(n, z->avail_out); |
||||
|
||||
/* update counters */ |
||||
z->avail_out -= n; |
||||
/* z->total_out += n; */ |
||||
|
||||
/* copy as far as end of window */ |
||||
zmemcpy(z->next_out, q, n); |
||||
z->next_out += n; |
||||
q += n; |
||||
|
||||
/* see if more to copy at beginning of window */ |
||||
if (q == s->end) |
||||
{ |
||||
/* wrap pointers */ |
||||
q = s->window; |
||||
if (s->write == s->end) |
||||
s->write = s->window; |
||||
|
||||
/* do the same for the beginning of the window */ |
||||
goto again; |
||||
} |
||||
|
||||
/* update pointers */ |
||||
s->read = q; |
||||
} |
||||
|
||||
#define BMAX 15 /* maximum bit length of any code */ |
||||
|
||||
local int ZEXPORT huft_build( |
||||
uIntf *b, /* code lengths in bits (all assumed <= BMAX) */ |
||||
uInt n, /* number of codes (assumed <= 288) */ |
||||
uInt s, /* number of simple-valued codes (0..s-1) */ |
||||
const unsigned short *d, /* list of base values for non-simple codes */ |
||||
const unsigned short *e, /* list of extra bits for non-simple codes */ |
||||
inflate_huft * FAR *t, /* result: starting table */ |
||||
uIntf *m, /* maximum lookup bits, returns actual */ |
||||
inflate_huft *hp, /* space for trees */ |
||||
uInt *hn) /* working area: values in order of bit length */ |
||||
{ |
||||
static uIntf v[288]; /* work area for huft_build */ |
||||
uInt a; /* counter for codes of length k */ |
||||
uInt c[BMAX+1]; /* bit length count table */ |
||||
uInt f; /* i repeats in table every f entries */ |
||||
int g; /* maximum code length */ |
||||
int h; /* table level */ |
||||
uInt i; /* counter, current code */ |
||||
uInt j; /* counter */ |
||||
int k; /* number of bits in current code */ |
||||
int l; /* bits per table (returned in m) */ |
||||
uIntf *p; /* pointer into c[], b[], or v[] */ |
||||
inflate_huft *q; /* points to current table */ |
||||
struct inflate_huft_s r; /* table entry for structure assignment */ |
||||
inflate_huft *u[BMAX]; /* table stack */ |
||||
int w; /* bits before this table == (l * h) */ |
||||
uInt x[BMAX+1]; /* bit offsets, then code stack */ |
||||
uIntf *xp; /* pointer into x */ |
||||
int y; /* number of dummy codes added */ |
||||
uInt z; /* number of entries in current table */ |
||||
|
||||
|
||||
/* Generate counts for each bit length */ |
||||
p=c; |
||||
y=16; while (y--) *p++ = 0; |
||||
p = b; |
||||
i = n; |
||||
do { |
||||
c[*p++]++; /* assume all entries <= BMAX */ |
||||
} while (--i); |
||||
if (c[0] == n) /* null input--all zero length codes */ |
||||
{ |
||||
*t = (inflate_huft *)Z_NULL; |
||||
*m = 0; |
||||
return Z_OK; |
||||
} |
||||
|
||||
|
||||
/* Find minimum and maximum length, bound *m by those */ |
||||
l = *m; |
||||
for (j = 1; j <= BMAX; j++) |
||||
if (c[j]) |
||||
break; |
||||
k = j; /* minimum code length */ |
||||
if ((uInt)l < j) |
||||
l = j; |
||||
for (i = BMAX; i; i--) |
||||
if (c[i]) |
||||
break; |
||||
g = i; /* maximum code length */ |
||||
if ((uInt)l > i) |
||||
l = i; |
||||
*m = l; |
||||
|
||||
|
||||
/* Adjust last length count to fill out codes, if needed */ |
||||
for (y = 1 << j; j < i; j++, y <<= 1) |
||||
if ((y -= c[j]) < 0) |
||||
return Z_DATA_ERROR; |
||||
if ((y -= c[i]) < 0) |
||||
return Z_DATA_ERROR; |
||||
c[i] += y; |
||||
|
||||
|
||||
/* Generate starting offsets into the value table for each length */ |
||||
x[1] = j = 0; |
||||
p = c + 1; xp = x + 2; |
||||
while (--i) { /* note that i == g from above */ |
||||
*xp++ = (j += *p++); |
||||
} |
||||
|
||||
|
||||
/* Make a table of values in order of bit lengths */ |
||||
p = b; i = 0; |
||||
do { |
||||
if ((j = *p++) != 0) |
||||
v[x[j]++] = i; |
||||
} while (++i < n); |
||||
n = x[g]; /* set n to length of v */ |
||||
|
||||
|
||||
/* Generate the Huffman codes and for each, make the table entries */ |
||||
x[0] = i = 0; /* first Huffman code is zero */ |
||||
p = v; /* grab values in bit order */ |
||||
h = -1; /* no tables yet--level -1 */ |
||||
w = -l; /* bits decoded == (l * h) */ |
||||
u[0] = (inflate_huft *)Z_NULL; /* just to keep compilers happy */ |
||||
q = (inflate_huft *)Z_NULL; /* ditto */ |
||||
z = 0; /* ditto */ |
||||
|
||||
r.base = 0; |
||||
|
||||
/* go through the bit lengths (k already is bits in shortest code) */ |
||||
for (; k <= g; k++) |
||||
{ |
||||
a = c[k]; |
||||
while (a--) |
||||
{ |
||||
int nextw=w; |
||||
/* here i is the Huffman code of length k bits for value *p */ |
||||
/* make tables up to required level */ |
||||
while (k > (nextw=w + l)) |
||||
{ |
||||
h++; |
||||
|
||||
/* compute minimum size table less than or equal to l bits */ |
||||
z = g - nextw; |
||||
z = z > (uInt)l ? (uInt)l : z; /* table size upper limit */ |
||||
if ((f = 1 << (j = k - nextw)) > a + 1) /* try a k-w bit table */ |
||||
{ /* too few codes for k-w bit table */ |
||||
f -= a + 1; /* deduct codes from patterns left */ |
||||
xp = c + k; |
||||
if (j < z) |
||||
while (++j < z && (f <<= 1) > *++xp) /* try smaller tables up to z bits */ |
||||
{ |
||||
f -= *xp; /* else deduct codes from patterns */ |
||||
} |
||||
} |
||||
z = 1 << j; /* table entries for j-bit table */ |
||||
|
||||
/* allocate new table */ |
||||
if (*hn + z > MANY) /* (note: doesn't matter for fixed) */ |
||||
return Z_MEM_ERROR; /* not enough memory */ |
||||
u[h] = q = hp + *hn; |
||||
*hn += z; |
||||
|
||||
/* connect to last table, if there is one */ |
||||
if (h) |
||||
{ |
||||
x[h] = i; /* save pattern for backing up */ |
||||
r.bits = (Byte)l; /* bits to dump before this table */ |
||||
r.exop = (Byte)j; /* bits in this table */ |
||||
j = i >> w; |
||||
r.base = (uInt)(q - u[h-1] - j); /* offset to this table */ |
||||
u[h-1][j] = r; /* connect to last table */ |
||||
} |
||||
else |
||||
*t = q; /* first table is returned result */ |
||||
w=nextw; /* previous table always l bits */ |
||||
} |
||||
|
||||
/* set up table entry in r */ |
||||
r.bits = (Byte)(k - w); |
||||
if (p >= v + n) |
||||
r.exop = 128 + 64; /* out of values--invalid code */ |
||||
else if (*p < s) |
||||
{ |
||||
r.exop = (Byte)(*p < 256 ? 0 : 32 + 64); /* 256 is end-of-block */ |
||||
r.base = *p++; /* simple code is just the value */ |
||||
} |
||||
else |
||||
{ |
||||
r.exop = (Byte)(e[*p - s] + 16 + 64);/* non-simple--look up in lists */ |
||||
r.base = d[*p++ - s]; |
||||
} |
||||
|
||||
/* fill code-like entries with r */ |
||||
f = 1 << (k - w); |
||||
for (j = i >> w; j < z; j += f) |
||||
q[j] = r; |
||||
|
||||
/* backwards increment the k-bit code i */ |
||||
for (j = 1 << (k - 1); i & j; j >>= 1) |
||||
i ^= j; |
||||
i ^= j; |
||||
|
||||
/* backup over finished tables */ |
||||
while ((i & ((1 << w) - 1)) != x[h]) |
||||
{ |
||||
h--; /* don't need to update q */ |
||||
w -= l; |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
/* Return Z_BUF_ERROR if we were given an incomplete table */ |
||||
return (y != 0 && g != 1) ? Z_BUF_ERROR : Z_OK; |
||||
} |
||||
|
||||
int ZEXPORT nsis_inflate(nsis_z_streamp z) |
||||
{ |
||||
inflate_blocks_statef *s = &z->blocks; |
||||
inflate_codes_statef *c = &s->sub.decode.t_codes; /* codes state */ |
||||
|
||||
/* lousy two bytes saved by doing this */ |
||||
struct |
||||
{ |
||||
uInt t; /* temporary storage */ |
||||
uLong b; /* bit buffer */ |
||||
uInt k; /* bits in bit buffer */ |
||||
Bytef *p; /* input data pointer */ |
||||
uInt n; /* bytes available there */ |
||||
Bytef *q; /* output window write pointer */ |
||||
uInt m; /* bytes to end of window or read pointer */ |
||||
|
||||
/* CODES variables */ |
||||
|
||||
inflate_huft *j; /* temporary pointer */ |
||||
uInt e; /* extra bits or operation */ |
||||
Bytef *f; /* pointer to copy strings from */ |
||||
} _state; |
||||
|
||||
#define t _state.t |
||||
#define b _state.b |
||||
#define k _state.k |
||||
#define p _state.p |
||||
#define n _state.n |
||||
#define q _state.q |
||||
#define m _state.m |
||||
|
||||
/* copy input/output information to locals (UPDATE macro restores) */ |
||||
LOAD |
||||
|
||||
/* process input based on current state */ |
||||
for (;;) switch (s->mode) |
||||
{ |
||||
case TYPE: |
||||
NEEDBITS(3) |
||||
t = (uInt)b & 7; |
||||
DUMPBITS(3) |
||||
s->last = (t & 1) ? DRY : TYPE; |
||||
switch (t >> 1) |
||||
{ |
||||
case 0: /* stored */ |
||||
Tracev((stderr, "inflate: stored block%s\n", |
||||
LAST ? " (last)" : "")); |
||||
DUMPBITS(k&7) |
||||
s->mode = LENS; /* get length of stored block */ |
||||
break; |
||||
case 1: /* fixed */ |
||||
Tracev((stderr, "inflate: fixed codes block%s\n", |
||||
LAST ? " (last)" : "")); |
||||
{ |
||||
if (!fixed_built) |
||||
{ |
||||
int _k; /* temporary variable */ |
||||
uInt f = 0; /* number of hufts used in fixed_mem */ |
||||
static uIntf lc[288]; /* length list for huft_build */ |
||||
|
||||
/* literal table */ |
||||
for (_k = 0; _k < 288; _k++) |
||||
{ |
||||
char v=8; |
||||
if (_k > 143) |
||||
{ |
||||
if (_k < 256) v++; |
||||
else if (_k < 280) v--; |
||||
} |
||||
lc[_k] = v; |
||||
} |
||||
|
||||
huft_build(lc, 288, 257, cplens, cplext, &fixed_tl, &fixed_bl, fixed_mem, &f); |
||||
|
||||
/* distance table */ |
||||
for (_k = 0; _k < 30; _k++) lc[_k] = 5; |
||||
|
||||
huft_build(lc, 30, 0, cpdist, cpdext, &fixed_td, &fixed_bd, fixed_mem, &f); |
||||
|
||||
/* done */ |
||||
fixed_built++; |
||||
} |
||||
|
||||
/* s->sub.decode.t_codes.mode = CODES_START; */ |
||||
s->sub.decode.t_codes.lbits = (Byte)fixed_bl; |
||||
s->sub.decode.t_codes.dbits = (Byte)fixed_bd; |
||||
s->sub.decode.t_codes.ltree = fixed_tl; |
||||
s->sub.decode.t_codes.dtree = fixed_td; |
||||
} |
||||
s->mode = CODES_START; |
||||
break; |
||||
case 2: /* dynamic */ |
||||
Tracev((stderr, "inflate: dynamic codes block%s\n", |
||||
LAST ? " (last)" : "")); |
||||
s->mode = TABLE; |
||||
break; |
||||
case 3: /* illegal */ |
||||
/* the only illegal value possible is 3 because we check only 2 bits */ |
||||
goto bad; |
||||
} |
||||
break; |
||||
case LENS: |
||||
NEEDBITS(16) |
||||
s->sub.left = (uInt)b & 0xffff; |
||||
b = k = 0; /* dump bits */ |
||||
Tracev((stderr, "inflate: stored length %u\n", s->sub.left)); |
||||
s->mode = s->sub.left ? STORED : (inflate_mode)s->last; |
||||
break; |
||||
case STORED: |
||||
{ |
||||
uInt mn; |
||||
|
||||
if (n == 0) |
||||
LEAVE(Z_OK) |
||||
NEEDOUT |
||||
mn = min(m, n); |
||||
t = min(s->sub.left, mn); |
||||
zmemcpy(q, p, t); |
||||
p += t; n -= t; |
||||
q += t; m -= t; |
||||
if (!(s->sub.left -= t)) |
||||
s->mode = (inflate_mode)s->last; |
||||
break; |
||||
} |
||||
case TABLE: |
||||
NEEDBITS(14) |
||||
s->sub.trees.table = t = (uInt)b & 0x3fff; |
||||
if ((t & 0x1f) > 29 || ((t >> 5) & 0x1f) > 29) |
||||
{ |
||||
s->mode = BAD; |
||||
LEAVE(Z_DATA_ERROR); |
||||
} |
||||
/* t = 258 + (t & 0x1f) + ((t >> 5) & 0x1f); */ |
||||
DUMPBITS(14) |
||||
s->sub.trees.index = 0; |
||||
Tracev((stderr, "inflate: table sizes ok\n")); |
||||
s->mode = BTREE; |
||||
case BTREE: |
||||
while (s->sub.trees.index < 4 + (s->sub.trees.table >> 10)) |
||||
{ |
||||
NEEDBITS(3) |
||||
s->sub.trees.t_blens[(int)border[s->sub.trees.index++]] = (uInt)b & 7; |
||||
DUMPBITS(3) |
||||
} |
||||
while (s->sub.trees.index < 19) |
||||
s->sub.trees.t_blens[(int)border[s->sub.trees.index++]] = 0; |
||||
s->sub.trees.bb = 7; |
||||
|
||||
{ |
||||
uInt hn = 0; /* hufts used in space */ |
||||
|
||||
t = huft_build(s->sub.trees.t_blens, 19, 19, Z_NULL, Z_NULL, |
||||
&s->sub.trees.tb, &s->sub.trees.bb, s->hufts, &hn); |
||||
if (t != Z_OK || !s->sub.trees.bb) |
||||
{ |
||||
s->mode = BAD; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
s->sub.trees.index = 0; |
||||
Tracev((stderr, "inflate: bits tree ok\n")); |
||||
s->mode = DTREE; |
||||
case DTREE: |
||||
while (t = s->sub.trees.table, |
||||
s->sub.trees.index < 258 + (t & 0x1f) + ((t >> 5) & 0x1f)) |
||||
{ |
||||
inflate_huft *h; |
||||
uInt i, j, d; |
||||
|
||||
t = s->sub.trees.bb; |
||||
NEEDBITS(t) |
||||
h = s->sub.trees.tb + ((uInt)b & (uInt)inflate_mask[t]); |
||||
t = h->bits; |
||||
d = h->base; |
||||
if (d < 16) |
||||
{ |
||||
DUMPBITS(t) |
||||
s->sub.trees.t_blens[s->sub.trees.index++] = d; |
||||
} |
||||
else /* d == 16..18 */ |
||||
{ |
||||
if (d == 18) |
||||
{ |
||||
i=7; |
||||
j=11; |
||||
} |
||||
else |
||||
{ |
||||
i=d-14; |
||||
j=3; |
||||
} |
||||
NEEDBITS(t+i) |
||||
DUMPBITS(t) |
||||
j += (uInt)b & (uInt)inflate_mask[i]; |
||||
DUMPBITS(i) |
||||
i = s->sub.trees.index; |
||||
t = s->sub.trees.table; |
||||
if (i + j > 258 + (t & 0x1f) + ((t >> 5) & 0x1f) || |
||||
(d == 16 && i < 1)) |
||||
{ |
||||
s->mode = BAD; |
||||
LEAVE(Z_DATA_ERROR); |
||||
} |
||||
d = d == 16 ? s->sub.trees.t_blens[i - 1] : 0; |
||||
do { |
||||
s->sub.trees.t_blens[i++] = d; |
||||
} while (--j); |
||||
s->sub.trees.index = i; |
||||
} |
||||
} |
||||
s->sub.trees.tb = Z_NULL; |
||||
{ |
||||
uInt hn = 0; /* hufts used in space */ |
||||
uInt bl, bd; |
||||
inflate_huft *tl, *td; |
||||
int nl,nd; |
||||
t = s->sub.trees.table; |
||||
|
||||
nl = 257 + (t & 0x1f); |
||||
nd = 1 + ((t >> 5) & 0x1f); |
||||
bl = 9; /* must be <= 9 for lookahead assumptions */ |
||||
bd = 6; /* must be <= 9 for lookahead assumptions */ |
||||
|
||||
t = huft_build(s->sub.trees.t_blens, nl, 257, cplens, cplext, &tl, &bl, s->hufts, &hn); |
||||
if (bl == 0) t = Z_DATA_ERROR; |
||||
if (t == Z_OK) |
||||
{ |
||||
/* build distance tree */ |
||||
t = huft_build(s->sub.trees.t_blens + nl, nd, 0, cpdist, cpdext, &td, &bd, s->hufts, &hn); |
||||
} |
||||
if (t != Z_OK || (bd == 0 && nl > 257)) |
||||
{ |
||||
s->mode = BAD; |
||||
LEAVE(Z_DATA_ERROR); |
||||
} |
||||
Tracev((stderr, "inflate: trees ok\n")); |
||||
|
||||
/* s->sub.decode.t_codes.mode = CODES_START; */ |
||||
s->sub.decode.t_codes.lbits = (Byte)bl; |
||||
s->sub.decode.t_codes.dbits = (Byte)bd; |
||||
s->sub.decode.t_codes.ltree = tl; |
||||
s->sub.decode.t_codes.dtree = td; |
||||
} |
||||
s->mode = CODES_START; |
||||
|
||||
#define j (_state.j) |
||||
#define e (_state.e) |
||||
#define f (_state.f) |
||||
|
||||
/* waiting for "i:"=input, "o:"=output, "x:"=nothing */ |
||||
|
||||
case CODES_START: /* x: set up for LEN */ |
||||
c->sub.code.need = c->lbits; |
||||
c->sub.code.tree = c->ltree; |
||||
s->mode = CODES_LEN; |
||||
case CODES_LEN: /* i: get length/literal/eob next */ |
||||
t = c->sub.code.need; |
||||
NEEDBITS(t) |
||||
j = c->sub.code.tree + ((uInt)b & (uInt)inflate_mask[t]); |
||||
DUMPBITS(j->bits) |
||||
e = (uInt)(j->exop); |
||||
if (e == 0) /* literal */ |
||||
{ |
||||
c->sub.lit = j->base; |
||||
s->mode = CODES_LIT; |
||||
break; |
||||
} |
||||
if (e & 16) /* length */ |
||||
{ |
||||
c->sub.copy.get = e & 15; |
||||
c->len = j->base; |
||||
s->mode = CODES_LENEXT; |
||||
break; |
||||
} |
||||
if ((e & 64) == 0) /* next table */ |
||||
{ |
||||
c->sub.code.need = e; |
||||
c->sub.code.tree = j + j->base; |
||||
break; |
||||
} |
||||
if (e & 32) /* end of block */ |
||||
{ |
||||
s->mode = CODES_WASH; |
||||
break; |
||||
} |
||||
goto bad; |
||||
case CODES_LENEXT: /* i: getting length extra (have base) */ |
||||
t = c->sub.copy.get; |
||||
NEEDBITS(t) |
||||
c->len += (uInt)b & (uInt)inflate_mask[t]; |
||||
DUMPBITS(t) |
||||
c->sub.code.need = c->dbits; |
||||
c->sub.code.tree = c->dtree; |
||||
s->mode = CODES_DIST; |
||||
case CODES_DIST: /* i: get distance next */ |
||||
t = c->sub.code.need; |
||||
NEEDBITS(t) |
||||
j = c->sub.code.tree + ((uInt)b & (uInt)inflate_mask[t]); |
||||
DUMPBITS(j->bits) |
||||
e = (uInt)(j->exop); |
||||
if (e & 16) /* distance */ |
||||
{ |
||||
c->sub.copy.get = e & 15; |
||||
c->sub.copy.dist = j->base; |
||||
s->mode = CODES_DISTEXT; |
||||
break; |
||||
} |
||||
if ((e & 64) == 0) /* next table */ |
||||
{ |
||||
c->sub.code.need = e; |
||||
c->sub.code.tree = j + j->base; |
||||
break; |
||||
} |
||||
goto bad; /* invalid code */ |
||||
case CODES_DISTEXT: /* i: getting distance extra */ |
||||
t = c->sub.copy.get; |
||||
NEEDBITS(t) |
||||
c->sub.copy.dist += (uInt)b & (uInt)inflate_mask[t]; |
||||
DUMPBITS(t) |
||||
s->mode = CODES_COPY; |
||||
case CODES_COPY: /* o: copying bytes in window, waiting for space */ |
||||
f = (uInt)(q - s->window) < c->sub.copy.dist ? |
||||
s->end - (c->sub.copy.dist - (q - s->window)) : |
||||
q - c->sub.copy.dist; |
||||
|
||||
while (c->len) |
||||
{ |
||||
NEEDOUT |
||||
OUTBYTE(*f++) |
||||
if (f == s->end) |
||||
f = s->window; |
||||
c->len--; |
||||
} |
||||
s->mode = CODES_START; |
||||
break; |
||||
case CODES_LIT: /* o: got literal, waiting for output space */ |
||||
NEEDOUT |
||||
OUTBYTE(c->sub.lit) |
||||
s->mode = CODES_START; |
||||
break; |
||||
case CODES_WASH: /* o: got eob, possibly more output */ |
||||
if (k > 7) /* return unused byte, if any */ |
||||
{ |
||||
k -= 8; |
||||
n++; |
||||
p--; /* can always return one */ |
||||
} |
||||
/* flushing will be done in DRY */ |
||||
|
||||
#undef j |
||||
#undef e |
||||
#undef f |
||||
|
||||
case DRY: |
||||
FLUSH |
||||
if (s->write != s->read) |
||||
LEAVE(Z_OK) |
||||
if (s->mode == CODES_WASH) |
||||
{ |
||||
Tracev((stderr, "inflate: codes end, %lu total out\n", |
||||
z->total_out + (q >= s->read ? q - s->read : |
||||
(s->end - s->read) + (q - s->window)))); |
||||
} |
||||
/* DRY if last, TYPE if not */ |
||||
s->mode = (inflate_mode)s->last; |
||||
if (s->mode == TYPE) |
||||
break; |
||||
LEAVE(Z_STREAM_END) |
||||
/*case BAD:
|
||||
r = Z_DATA_ERROR; |
||||
LEAVE |
||||
*/ |
||||
default: /* we'll call Z_STREAM_ERROR if BAD anyway */ |
||||
bad: |
||||
s->mode = BAD; |
||||
LEAVE(Z_STREAM_ERROR) |
||||
} |
||||
} |
||||
|
||||
#undef t |
||||
#undef b |
||||
#undef k |
||||
#undef p |
||||
#undef n |
||||
#undef q |
||||
#undef m |
||||
@ -0,0 +1,266 @@ |
||||
|
||||
/*-------------------------------------------------------------*/ |
||||
/*--- Public header file for the library. ---*/ |
||||
/*--- bzlib.h ---*/ |
||||
/*-------------------------------------------------------------*/ |
||||
|
||||
/* ------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for |
||||
lossless, block-sorting data compression. |
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006 |
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org> |
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||
README file. |
||||
|
||||
This program is released under the terms of the license contained |
||||
in the file LICENSE. |
||||
------------------------------------------------------------------ */ |
||||
|
||||
|
||||
#ifndef _NSIS_BZLIB_H |
||||
#define _NSIS_BZLIB_H |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
#define BZ_RUN 0 |
||||
#define BZ_FLUSH 1 |
||||
#define BZ_FINISH 2 |
||||
|
||||
#define BZ_OK 0 |
||||
#define BZ_RUN_OK 1 |
||||
#define BZ_FLUSH_OK 2 |
||||
#define BZ_FINISH_OK 3 |
||||
#define BZ_STREAM_END 4 |
||||
#define BZ_SEQUENCE_ERROR (-1) |
||||
#define BZ_PARAM_ERROR (-2) |
||||
#define BZ_MEM_ERROR (-3) |
||||
#define BZ_DATA_ERROR (-4) |
||||
#define BZ_DATA_ERROR_MAGIC (-5) |
||||
#define BZ_IO_ERROR (-6) |
||||
#define BZ_UNEXPECTED_EOF (-7) |
||||
#define BZ_OUTBUFF_FULL (-8) |
||||
#define BZ_CONFIG_ERROR (-9) |
||||
|
||||
typedef
|
||||
struct { |
||||
unsigned char *next_in; |
||||
unsigned int avail_in; |
||||
unsigned int total_in_lo32; |
||||
unsigned int total_in_hi32; |
||||
|
||||
unsigned char *next_out; |
||||
unsigned int avail_out; |
||||
unsigned int total_out_lo32; |
||||
unsigned int total_out_hi32; |
||||
|
||||
void *state; |
||||
|
||||
void *(*bzalloc)(void *,int,int); |
||||
void (*bzfree)(void *,void *); |
||||
void *opaque; |
||||
}
|
||||
nsis_bzstream; |
||||
|
||||
|
||||
#ifndef BZ_IMPORT |
||||
#define BZ_EXPORT |
||||
#endif |
||||
|
||||
#ifndef BZ_NO_STDIO |
||||
/* Need a definitition for FILE */ |
||||
#include <stdio.h> |
||||
#endif |
||||
|
||||
|
||||
#define BZ_API(func) func |
||||
#define BZ_EXTERN extern |
||||
|
||||
|
||||
/*-- Core (low-level) library functions --*/ |
||||
/* aCaB
|
||||
BZ_EXTERN int BZ_API(BZ2_bzCompressInit) (
|
||||
nsis_bzstream* strm,
|
||||
int blockSize100k,
|
||||
int verbosity,
|
||||
int workFactor
|
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzCompress) (
|
||||
nsis_bzstream* strm,
|
||||
int action
|
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) (
|
||||
nsis_bzstream* strm
|
||||
); |
||||
*/ |
||||
BZ_EXTERN int BZ_API(nsis_BZ2_bzDecompressInit) (
|
||||
nsis_bzstream *strm,
|
||||
int verbosity,
|
||||
int small |
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(nsis_BZ2_bzDecompress) (
|
||||
nsis_bzstream* strm
|
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(nsis_BZ2_bzDecompressEnd) (
|
||||
nsis_bzstream *strm
|
||||
); |
||||
|
||||
|
||||
|
||||
/*-- High(er) level library functions --*/ |
||||
/* aCaB
|
||||
#ifndef BZ_NO_STDIO |
||||
#define BZ_MAX_UNUSED 5000 |
||||
|
||||
typedef void BZFILE; |
||||
|
||||
BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) (
|
||||
int* bzerror,
|
||||
FILE* f,
|
||||
int verbosity,
|
||||
int small, |
||||
void* unused,
|
||||
int nUnused
|
||||
); |
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzReadClose) (
|
||||
int* bzerror,
|
||||
BZFILE* b
|
||||
); |
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
void** unused,
|
||||
int* nUnused
|
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzRead) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
); |
||||
|
||||
BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) (
|
||||
int* bzerror,
|
||||
FILE* f,
|
||||
int blockSize100k,
|
||||
int verbosity,
|
||||
int workFactor
|
||||
); |
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzWrite) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
); |
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzWriteClose) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
int abandon,
|
||||
unsigned int* nbytes_in,
|
||||
unsigned int* nbytes_out
|
||||
); |
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) (
|
||||
int* bzerror,
|
||||
BZFILE* b,
|
||||
int abandon,
|
||||
unsigned int* nbytes_in_lo32,
|
||||
unsigned int* nbytes_in_hi32,
|
||||
unsigned int* nbytes_out_lo32,
|
||||
unsigned int* nbytes_out_hi32 |
||||
); |
||||
#endif |
||||
*/ |
||||
/*-- Utility functions --*/ |
||||
/* aCaB
|
||||
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) (
|
||||
char* dest,
|
||||
unsigned int* destLen, |
||||
char* source,
|
||||
unsigned int sourceLen, |
||||
int blockSize100k,
|
||||
int verbosity,
|
||||
int workFactor
|
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) (
|
||||
char* dest,
|
||||
unsigned int* destLen, |
||||
char* source,
|
||||
unsigned int sourceLen, |
||||
int small,
|
||||
int verbosity
|
||||
); |
||||
*/ |
||||
|
||||
/*--
|
||||
Code contributed by Yoshioka Tsuneo (tsuneo@rr.iij4u.or.jp) |
||||
to support better zlib compatibility. |
||||
This code is not _officially_ part of libbzip2 (yet); |
||||
I haven't tested it, documented it, or considered the |
||||
threading-safeness of it. |
||||
If this code breaks, please contact both Yoshioka and me. |
||||
--*/ |
||||
/* aCaB
|
||||
BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( |
||||
void |
||||
); |
||||
|
||||
#ifndef BZ_NO_STDIO |
||||
BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( |
||||
const char *path, |
||||
const char *mode |
||||
); |
||||
|
||||
BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( |
||||
int fd, |
||||
const char *mode |
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzread) ( |
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzwrite) ( |
||||
BZFILE* b,
|
||||
void* buf,
|
||||
int len
|
||||
); |
||||
|
||||
BZ_EXTERN int BZ_API(BZ2_bzflush) ( |
||||
BZFILE* b |
||||
); |
||||
|
||||
BZ_EXTERN void BZ_API(BZ2_bzclose) ( |
||||
BZFILE* b |
||||
); |
||||
|
||||
BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( |
||||
BZFILE *b,
|
||||
int *errnum |
||||
); |
||||
#endif |
||||
*/ |
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif |
||||
|
||||
/*-------------------------------------------------------------*/ |
||||
/*--- end bzlib.h ---*/ |
||||
/*-------------------------------------------------------------*/ |
||||
@ -0,0 +1,58 @@ |
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-1998 Jean-loup Gailly. |
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/ |
||||
|
||||
/* @(#) $Id: ZCONF.H,v 1.3 2007/01/13 17:28:23 kichik Exp $ */ |
||||
|
||||
#ifndef _ZCONF_H |
||||
#define _ZCONF_H |
||||
|
||||
|
||||
#define MAX_MEM_LEVEL 9 |
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files |
||||
* created by gzip. (Files created by minigzip can still be extracted by |
||||
* gzip.) |
||||
*/ |
||||
#ifndef MAX_WBITS |
||||
# define MAX_WBITS 15 /* 32K LZ77 window */ |
||||
#endif |
||||
|
||||
#define OF(args) args |
||||
|
||||
|
||||
#ifndef ZEXPORT |
||||
# define ZEXPORT |
||||
#endif |
||||
#ifndef ZEXPORTVA |
||||
# define ZEXPORTVA |
||||
#endif |
||||
#ifndef ZEXTERN |
||||
# define ZEXTERN extern |
||||
#endif |
||||
|
||||
#ifndef FAR |
||||
# define FAR |
||||
#endif |
||||
|
||||
typedef unsigned char Byte; /* 8 bits */ |
||||
typedef unsigned int uInt; /* 16 bits or more */ |
||||
typedef unsigned long uLong; /* 32 bits or more */ |
||||
|
||||
typedef Byte FAR Bytef; |
||||
typedef char FAR charf; |
||||
typedef int FAR intf; |
||||
typedef uInt FAR uIntf; |
||||
typedef uLong FAR uLongf; |
||||
|
||||
typedef void FAR *voidpf; |
||||
typedef void *voidp; |
||||
|
||||
#ifndef z_off_t |
||||
# define z_off_t long |
||||
#endif |
||||
|
||||
|
||||
#endif /* _ZCONF_H */ |
||||
@ -0,0 +1,220 @@ |
||||
/* zlib.h -- interface of the 'zlib' general purpose compression library
|
||||
version 1.1.3, July 9th, 1998 |
||||
|
||||
Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler |
||||
|
||||
This software is provided 'as-is', without any express or implied |
||||
warranty. In no event will the authors be held liable for any damages |
||||
arising from the use of this software. |
||||
|
||||
Permission is granted to anyone to use this software for any purpose, |
||||
including commercial applications, and to alter it and redistribute it |
||||
freely, subject to the following restrictions: |
||||
|
||||
1. The origin of this software must not be misrepresented; you must not |
||||
claim that you wrote the original software. If you use this software |
||||
in a product, an acknowledgment in the product documentation would be |
||||
appreciated but is not required. |
||||
2. Altered source versions must be plainly marked as such, and must not be |
||||
misrepresented as being the original software. |
||||
3. This notice may not be removed or altered from any source distribution. |
||||
|
||||
Jean-loup Gailly Mark Adler |
||||
jloup@gzip.org madler@alumni.caltech.edu |
||||
|
||||
|
||||
*/ |
||||
|
||||
#ifndef _ZLIB_H |
||||
#define _ZLIB_H |
||||
|
||||
#include "nsis_zconf.h" |
||||
#include "nsis_zutil.h" |
||||
|
||||
#ifdef __cplusplus |
||||
extern "C" { |
||||
#endif |
||||
|
||||
|
||||
typedef struct inflate_huft_s FAR inflate_huft; |
||||
|
||||
|
||||
|
||||
typedef enum { /* waiting for "i:"=input, "o:"=output, "x:"=nothing */ |
||||
CODES_START, /* x: set up for LEN */ |
||||
CODES_LEN, /* i: get length/literal/eob next */ |
||||
CODES_LENEXT, /* i: getting length extra (have base) */ |
||||
CODES_DIST, /* i: get distance next */ |
||||
CODES_DISTEXT, /* i: getting distance extra */ |
||||
CODES_COPY, /* o: copying bytes in window, waiting for space */ |
||||
CODES_LIT, /* o: got literal, waiting for output space */ |
||||
CODES_WASH, /* o: got eob, possibly still output waiting */ |
||||
/* CODES_END, x: got eob and all data flushed */ |
||||
/* CODES_BADCODE, x: got error */ |
||||
|
||||
TYPE, /* get type bits (3, including end bit) */ |
||||
LENS, /* get lengths for stored */ |
||||
STORED, /* processing stored block */ |
||||
TABLE, /* get table lengths */ |
||||
BTREE, /* get bit lengths tree for a dynamic block */ |
||||
DTREE, /* get length, distance trees for a dynamic block */ |
||||
CODES, /* processing fixed or dynamic block */ |
||||
DRY, /* output remaining window bytes */ |
||||
DONE, /* finished last block, done */ |
||||
BAD /* got a data error--stuck here */ |
||||
} inflate_mode; |
||||
|
||||
/* inflate codes private state */ |
||||
struct inflate_codes_state { |
||||
|
||||
/* mode */ |
||||
/* inflate_mode mode; current inflate_codes mode */ |
||||
|
||||
/* mode dependent information */ |
||||
uInt len; |
||||
union { |
||||
struct { |
||||
inflate_huft *tree; /* pointer into tree */ |
||||
uInt need; /* bits needed */ |
||||
} code; /* if LEN or DIST, where in tree */ |
||||
uInt lit; /* if LIT, literal */ |
||||
struct { |
||||
uInt get; /* bits to get for extra */ |
||||
uInt dist; /* distance back to copy from */ |
||||
} copy; /* if EXT or COPY, where and how much */ |
||||
} sub; /* submode */ |
||||
|
||||
/* mode independent information */ |
||||
Byte lbits; /* ltree bits decoded per branch */ |
||||
Byte dbits; /* dtree bits decoder per branch */ |
||||
inflate_huft *ltree; /* literal/length/eob tree */ |
||||
inflate_huft *dtree; /* distance tree */ |
||||
|
||||
}; |
||||
|
||||
struct inflate_huft_s { |
||||
union { |
||||
struct { |
||||
Byte Exop; /* number of extra bits or operation */ |
||||
Byte Bits; /* number of bits in this code or subcode */ |
||||
} what; |
||||
} word; |
||||
unsigned short base; /* literal, length base, distance base,
|
||||
or table offset */ |
||||
}; |
||||
|
||||
#define MANY 1440 |
||||
|
||||
typedef struct inflate_codes_state inflate_codes_statef; |
||||
|
||||
struct inflate_blocks_state { |
||||
|
||||
/* mode */ |
||||
inflate_mode mode; /* current inflate_block mode */ |
||||
|
||||
/* mode dependent information */ |
||||
union { |
||||
uInt left; /* if STORED, bytes left to copy */ |
||||
struct { |
||||
uInt table; /* table lengths (14 bits) */ |
||||
uInt index; /* index into blens (or border) */ |
||||
uIntf t_blens[258+31+31]; /* bit lengths of codes */ |
||||
uInt bb; /* bit length tree depth */ |
||||
inflate_huft *tb; /* bit length decoding tree */ |
||||
} trees; /* if DTREE, decoding info for trees */ |
||||
struct { |
||||
inflate_codes_statef t_codes; |
||||
} decode; /* if CODES, current state */ |
||||
} sub; /* submode */ |
||||
|
||||
uInt last; /* DRY if this block is the last block, TYPE otherwise */ |
||||
|
||||
/* mode independent information */ |
||||
uInt bitk; /* bits in bit buffer */ |
||||
uLong bitb; /* bit buffer */ |
||||
inflate_huft hufts[MANY]; /* single malloc for tree space */ |
||||
Bytef window[1 << MAX_WBITS]; /* sliding window */ |
||||
Bytef *end; /* one byte after sliding window */ |
||||
Bytef *read; /* window read pointer */ |
||||
Bytef *write; /* window write pointer */ |
||||
uLong check; /* check on output */ |
||||
|
||||
}; |
||||
|
||||
typedef struct nsis_z_stream_s { |
||||
Bytef *next_in; /* next input byte */ |
||||
uInt avail_in; /* number of bytes available at next_in */ |
||||
uLong total_in; /* total nb of input bytes read so far */ |
||||
|
||||
Bytef *next_out; /* next output byte should be put there */ |
||||
uInt avail_out; /* remaining free space at next_out */ |
||||
|
||||
/* char *msg; last error message, NULL if no error */ |
||||
/* struct internal_state FAR *state; not visible by applications */ |
||||
struct inflate_blocks_state blocks; |
||||
|
||||
} nsis_z_stream; |
||||
|
||||
typedef nsis_z_stream FAR *nsis_z_streamp; |
||||
|
||||
|
||||
#define Z_NO_FLUSH 0 |
||||
#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ |
||||
#define Z_SYNC_FLUSH 2 |
||||
#define Z_FULL_FLUSH 3 |
||||
#define Z_FINISH 4 |
||||
/* Allowed flush values; see deflate() below for details */ |
||||
|
||||
#define Z_OK 0 |
||||
#define Z_STREAM_END 1 |
||||
#define Z_NEED_DICT 2 |
||||
#define Z_ERRNO (-1) |
||||
|
||||
/* EXEHEAD doesn't need a specific return code, just < 0 */ |
||||
#define Z_STREAM_ERROR (-2) |
||||
#define Z_DATA_ERROR (-3) |
||||
#define Z_MEM_ERROR (-4) |
||||
#define Z_BUF_ERROR (-5) |
||||
#define Z_VERSION_ERROR (-6) |
||||
|
||||
/* Return codes for the compression/decompression functions. Negative
|
||||
* values are errors, positive values are used for special but normal events. |
||||
*/ |
||||
|
||||
#define Z_NO_COMPRESSION 0 |
||||
#define Z_BEST_SPEED 1 |
||||
#define Z_BEST_COMPRESSION 9 |
||||
#define Z_DEFAULT_COMPRESSION (-1) |
||||
/* compression levels */ |
||||
|
||||
#define Z_FILTERED 1 |
||||
#define Z_HUFFMAN_ONLY 2 |
||||
#define Z_DEFAULT_STRATEGY 0 |
||||
/* compression strategy; see deflateInit2() below for details */ |
||||
|
||||
#define Z_BINARY 0 |
||||
#define Z_ASCII 1 |
||||
#define Z_UNKNOWN 2 |
||||
/* Possible values of the data_type field */ |
||||
|
||||
#define Z_DEFLATED 8 |
||||
/* The deflate compression method (the only one supported in this version) */ |
||||
|
||||
#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ |
||||
|
||||
|
||||
#define nsis_inflateInit(x) inflateReset(x) |
||||
int ZEXPORT nsis_inflate(nsis_z_streamp z); |
||||
#define inflateReset(z) \ |
||||
{ \
|
||||
(z)->blocks.mode = TYPE; \
|
||||
(z)->blocks.bitk = (z)->blocks.bitb = 0; \
|
||||
(z)->blocks.read = (z)->blocks.write = (z)->blocks.window; \
|
||||
(z)->blocks.end = (z)->blocks.window + (1 << DEF_WBITS); \
|
||||
} |
||||
|
||||
#ifdef __cplusplus |
||||
} |
||||
#endif |
||||
|
||||
#endif /* _ZLIB_H */ |
||||
@ -0,0 +1,74 @@ |
||||
/*
|
||||
* This file is a part of the zlib compression module for NSIS. |
||||
*
|
||||
* Copyright and license information can be found below. |
||||
* Modifications Copyright (C) 1999-2007 Nullsoft and Contributors |
||||
*
|
||||
* The original zlib source code is available at |
||||
* http://www.zlib.net/
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied |
||||
* warranty. |
||||
*/ |
||||
|
||||
/* zutil.h -- internal interface and configuration of the compression library
|
||||
* Copyright (C) 1995-1998 Jean-loup Gailly. |
||||
* For conditions of distribution and use, see copyright notice in zlib.h |
||||
*/ |
||||
|
||||
/* WARNING: this file should *not* be used by applications. It is
|
||||
part of the implementation of the compression library and is |
||||
subject to change. Applications should only use zlib.h. |
||||
*/ |
||||
|
||||
/* @(#) $Id: ZUTIL.H,v 1.6 2007/01/25 18:07:40 kichik Exp $ */ |
||||
|
||||
#ifndef _Z_UTIL_H |
||||
#define _Z_UTIL_H |
||||
|
||||
#include "nsis_zlib.h" |
||||
|
||||
#ifndef local |
||||
# define local static |
||||
#endif |
||||
|
||||
typedef unsigned char uch; |
||||
typedef uch FAR uchf; |
||||
typedef unsigned short ush; |
||||
typedef ush FAR ushf; |
||||
typedef unsigned long ulg; |
||||
|
||||
#ifndef DEF_WBITS |
||||
# define DEF_WBITS MAX_WBITS |
||||
#endif |
||||
/* default windowBits for decompression. MAX_WBITS is for compression only */ |
||||
|
||||
#define DEF_MEM_LEVEL MAX_MEM_LEVEL |
||||
|
||||
#define STORED_BLOCK 0 |
||||
#define STATIC_TREES 1 |
||||
#define DYN_TREES 2 |
||||
/* The three kinds of block type */ |
||||
|
||||
#define MIN_MATCH 3 |
||||
#define MAX_MATCH 258 |
||||
/* The minimum and maximum match lengths */ |
||||
|
||||
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ |
||||
|
||||
|
||||
#define zmemcpy memcpy |
||||
|
||||
#define Assert(cond,msg) |
||||
#define Trace(x) |
||||
#define Tracev(x) |
||||
#define Tracevv(x) |
||||
#define Tracec(c,x) |
||||
#define Tracecv(c,x) |
||||
|
||||
#define ZALLOC(strm, items, size) malloc((items)*(size)) |
||||
#define ZFREE(strm, addr) { if (addr) free(addr); } |
||||
#define TRY_FREE(s, p) { ZFREE(s, p); } |
||||
#define ERR_RETURN(strm,err) return (err) |
||||
|
||||
#endif /* _Z_UTIL_H */ |
||||
@ -0,0 +1,463 @@ |
||||
/*
|
||||
* Copyright (C) 2007 aCaB <acab@clamav.net> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License version 2 as |
||||
* published by the Free Software Foundation. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
||||
* MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
#if HAVE_CONFIG_H |
||||
#include "clamav-config.h" |
||||
#endif |
||||
|
||||
#include <stdio.h> |
||||
#include <sys/types.h> |
||||
#include <sys/stat.h> |
||||
#include <fcntl.h> |
||||
#include <unistd.h> |
||||
#include <string.h> |
||||
#ifdef HAVE_UNISTD_H |
||||
#include <unistd.h> |
||||
#endif |
||||
|
||||
#include "nulsft.h" |
||||
#include "others.h" |
||||
#include "cltypes.h" |
||||
#ifdef HAVE_BZLIB_H |
||||
#include "nsis_bzlib.h" |
||||
#endif |
||||
#include "LZMADecode.h" |
||||
#include "nsis_zlib.h" |
||||
|
||||
#ifndef O_BINARY |
||||
#define O_BINARY 0 |
||||
#endif |
||||
|
||||
#define EC32(x) le32_to_host(x) |
||||
|
||||
enum { |
||||
COMP_NOT_DETECTED, |
||||
COMP_BZIP2, |
||||
COMP_LZMA, |
||||
COMP_ZLIB, |
||||
COMP_NOCOMP |
||||
}; |
||||
|
||||
#define LINESTR(x) #x |
||||
#define LINESTR2(x) LINESTR(x) |
||||
#define __AT__ " at "__FILE__":"LINESTR2(__LINE__) |
||||
|
||||
static int nsis_init(struct nsis_st *n) { |
||||
switch(n->comp) { |
||||
case COMP_BZIP2: |
||||
#ifdef HAVE_BZLIB_H |
||||
if (nsis_BZ2_bzDecompressInit(&n->bz, 0, 0)!=BZ_OK) |
||||
return CL_EBZIP; |
||||
n->freecomp=1; |
||||
break; |
||||
#else |
||||
cli_warnmsg("NSIS: Bzip2 support not compiled in\n"); |
||||
return CL_ESUPPORT; |
||||
#endif |
||||
case COMP_LZMA: |
||||
lzmaInit(&n->lz); |
||||
n->freecomp=1; |
||||
break; |
||||
case COMP_ZLIB: |
||||
nsis_inflateInit(&n->z); |
||||
n->freecomp=0; |
||||
} |
||||
return CL_SUCCESS; |
||||
} |
||||
|
||||
static void nsis_shutdown(struct nsis_st *n) { |
||||
if(!n->freecomp) |
||||
return; |
||||
|
||||
switch(n->comp) { |
||||
case COMP_BZIP2: |
||||
#ifdef HAVE_BZLIB_H |
||||
nsis_BZ2_bzDecompressEnd(&n->bz); |
||||
#endif |
||||
break; |
||||
case COMP_LZMA: |
||||
lzmaShutdown(&n->lz); |
||||
case COMP_ZLIB: |
||||
break; |
||||
} |
||||
|
||||
n->freecomp=0; |
||||
} |
||||
|
||||
static int nsis_decomp(struct nsis_st *n) { |
||||
int ret = CL_EFORMAT; |
||||
switch(n->comp) { |
||||
case COMP_BZIP2: |
||||
#ifdef HAVE_BZLIB_H |
||||
n->bz.avail_in = n->nsis.avail_in; |
||||
n->bz.next_in = n->nsis.next_in; |
||||
n->bz.avail_out = n->nsis.avail_out; |
||||
n->bz.next_out = n->nsis.next_out; |
||||
switch (nsis_BZ2_bzDecompress(&n->bz)) { |
||||
case BZ_OK: |
||||
ret = CL_SUCCESS; |
||||
break; |
||||
case BZ_STREAM_END: |
||||
ret = CL_BREAK; |
||||
} |
||||
n->nsis.avail_in = n->bz.avail_in; |
||||
n->nsis.next_in = n->bz.next_in; |
||||
n->nsis.avail_out = n->bz.avail_out; |
||||
n->nsis.next_out = n->bz.next_out; |
||||
#endif /* HAVE_BZLIB_H */ |
||||
break; |
||||
case COMP_LZMA: |
||||
n->lz.avail_in = n->nsis.avail_in; |
||||
n->lz.next_in = n->nsis.next_in; |
||||
n->lz.avail_out = n->nsis.avail_out; |
||||
n->lz.next_out = n->nsis.next_out; |
||||
switch (lzmaDecode(&n->lz)) { |
||||
case LZMA_OK: |
||||
ret = CL_SUCCESS; |
||||
break; |
||||
case LZMA_STREAM_END: |
||||
ret = CL_BREAK; |
||||
} |
||||
n->nsis.avail_in = n->lz.avail_in; |
||||
n->nsis.next_in = n->lz.next_in; |
||||
n->nsis.avail_out = n->lz.avail_out; |
||||
n->nsis.next_out = n->lz.next_out; |
||||
break; |
||||
case COMP_ZLIB: |
||||
n->z.avail_in = n->nsis.avail_in; |
||||
n->z.next_in = n->nsis.next_in; |
||||
n->z.avail_out = n->nsis.avail_out; |
||||
n->z.next_out = n->nsis.next_out; |
||||
switch (nsis_inflate(&n->z)) { |
||||
case Z_OK: |
||||
ret = CL_SUCCESS; |
||||
break; |
||||
case Z_STREAM_END: |
||||
ret = CL_BREAK; |
||||
} |
||||
n->nsis.avail_in = n->z.avail_in; |
||||
n->nsis.next_in = n->z.next_in; |
||||
n->nsis.avail_out = n->z.avail_out; |
||||
n->nsis.next_out = n->z.next_out; |
||||
break; |
||||
} |
||||
return ret; |
||||
} |
||||
|
||||
static int nsis_unpack_next(struct nsis_st *n, cli_ctx *ctx) { |
||||
unsigned char *ibuf; |
||||
uint32_t size, loops; |
||||
int ret; |
||||
unsigned char obuf[BUFSIZ]; |
||||
|
||||
if (n->eof) { |
||||
cli_dbgmsg("NSIS: extraction complete\n"); |
||||
return CL_BREAK; |
||||
} |
||||
if (ctx->limits && ctx->limits->maxfiles && n->fno >= ctx->limits->maxfiles) { |
||||
cli_dbgmsg("NSIS: Files limit reached (max: %u)\n", ctx->limits->maxfiles); |
||||
return CL_EMAXFILES; |
||||
} |
||||
|
||||
if (n->fno) |
||||
snprintf(n->ofn, 1023, "%s/content.%.3u", n->dir, n->fno); |
||||
else |
||||
snprintf(n->ofn, 1023, "%s/headers", n->dir); |
||||
|
||||
n->fno++; |
||||
|
||||
if ((n->ofd=open(n->ofn, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0600))==-1) { |
||||
cli_errmsg("NSIS: unable to create output file %s - aborting.", n->ofn); |
||||
return CL_EIO; |
||||
} |
||||
|
||||
if (!n->solid) { |
||||
if (cli_readn(n->ifd, &size, 4)!=4) { |
||||
cli_dbgmsg("NSIS: reached EOF - extraction complete\n"); |
||||
close(n->ofd); |
||||
return CL_BREAK; |
||||
} |
||||
if (n->asz==4) { |
||||
cli_dbgmsg("NSIS: reached CRC - extraction complete\n"); |
||||
close(n->ofd); |
||||
return CL_BREAK; |
||||
} |
||||
loops = EC32(size); |
||||
if (!(size = (loops&~0x80000000))) { |
||||
cli_dbgmsg("NSIS: empty file found\n"); |
||||
return CL_SUCCESS; |
||||
} |
||||
if (n->asz <4 || size > n->asz-4) { |
||||
cli_dbgmsg("NSIS: next file is outside the archive\n"); |
||||
close(n->ofd); |
||||
return CL_BREAK; |
||||
} |
||||
|
||||
n->asz -= size+4; |
||||
|
||||
if (ctx->limits && ctx->limits->maxfilesize && size > ctx->limits->maxfilesize) { |
||||
cli_dbgmsg("NSIS: Skipping file due to size limit (%u, max: %lu)\n", size, ctx->limits->maxfilesize); |
||||
close(n->ofd); |
||||
if (lseek(n->ifd, size, SEEK_CUR)==-1) return CL_EIO; |
||||
return CL_EMAXSIZE; |
||||
} |
||||
if (!(ibuf= (unsigned char *) cli_malloc(size))) { |
||||
cli_dbgmsg("NSIS: out of memory"__AT__"\n"); |
||||
close(n->ofd); |
||||
return CL_EMEM; |
||||
} |
||||
if (cli_readn(n->ifd, ibuf, size) != (ssize_t) size) { |
||||
cli_dbgmsg("NSIS: cannot read %u bytes"__AT__"\n", size); |
||||
free(ibuf); |
||||
close(n->ofd); |
||||
return CL_EIO; |
||||
} |
||||
if (loops==size) { |
||||
if (cli_writen(n->ofd, ibuf, size) != (ssize_t) size) { |
||||
cli_dbgmsg("NSIS: cannot write output file"__AT__"\n"); |
||||
free(ibuf); |
||||
close(n->ofd); |
||||
return CL_EIO; |
||||
} |
||||
} else { |
||||
if ((ret=nsis_init(n))!=CL_SUCCESS) { |
||||
cli_dbgmsg("NSIS: decompressor init failed"__AT__"\n"); |
||||
free(ibuf); |
||||
close(n->ofd); |
||||
return ret; |
||||
} |
||||
|
||||
n->nsis.avail_in = size; |
||||
n->nsis.next_in = ibuf; |
||||
n->nsis.next_out = obuf; |
||||
n->nsis.avail_out = BUFSIZ; |
||||
loops=0; |
||||
|
||||
while ((ret=nsis_decomp(n))==CL_SUCCESS) { |
||||
if ((size = n->nsis.next_out - obuf)) { |
||||
if (cli_writen(n->ofd, obuf, size) != (ssize_t) size) { |
||||
cli_dbgmsg("NSIS: cannot write output file"__AT__"\n"); |
||||
free(ibuf); |
||||
close(n->ofd); |
||||
return CL_EIO; |
||||
} |
||||
n->nsis.next_out = obuf; |
||||
n->nsis.avail_out = BUFSIZ; |
||||
loops=0; |
||||
if (ctx->limits && ctx->limits->maxfilesize && size > ctx->limits->maxfilesize) { |
||||
cli_dbgmsg("NSIS: Skipping file due to size limit (%u, max: %lu)\n", size, ctx->limits->maxfilesize); |
||||
free(ibuf); |
||||
close(n->ofd); |
||||
nsis_shutdown(n); |
||||
return CL_EMAXSIZE; |
||||
} |
||||
} else if (++loops > 10) { |
||||
cli_dbgmsg("NSIS: xs looping, breaking out"__AT__"\n"); |
||||
ret = CL_BREAK; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (ret != CL_BREAK) { |
||||
cli_dbgmsg("NSIS: bad stream"__AT__"\n"); |
||||
free(ibuf); |
||||
close(n->ofd); |
||||
return CL_EFORMAT; |
||||
} |
||||
|
||||
if (cli_writen(n->ofd, obuf, n->nsis.next_out - obuf) != n->nsis.next_out - obuf) { |
||||
cli_dbgmsg("NSIS: cannot write output file"__AT__"\n"); |
||||
free(ibuf); |
||||
close(n->ofd); |
||||
return CL_EIO; |
||||
} |
||||
nsis_shutdown(n); |
||||
} |
||||
|
||||
free(ibuf); |
||||
return CL_SUCCESS; |
||||
|
||||
} else { |
||||
if (!n->freeme) { |
||||
if ((ret=nsis_init(n))!=CL_SUCCESS) { |
||||
cli_dbgmsg("NSIS: decompressor init failed\n"); |
||||
close(n->ofd); |
||||
return ret; |
||||
} |
||||
if (!(n->freeme= (unsigned char *) cli_malloc(n->asz))) { |
||||
cli_dbgmsg("NSIS: out of memory\n"); |
||||
close(n->ofd); |
||||
return CL_EMEM; |
||||
} |
||||
if (cli_readn(n->ifd, n->freeme, n->asz) != (ssize_t) n->asz) { |
||||
cli_dbgmsg("NSIS: cannot read %u bytes"__AT__"\n", size); |
||||
close(n->ofd); |
||||
return CL_EIO; |
||||
} |
||||
n->nsis.next_in = n->freeme; |
||||
n->nsis.avail_in = n->asz; |
||||
} |
||||
|
||||
if (n->nsis.avail_in<=4) { |
||||
cli_dbgmsg("NSIS: extraction complete\n"); |
||||
close(n->ofd); |
||||
return CL_BREAK; |
||||
} |
||||
n->nsis.next_out = obuf; |
||||
n->nsis.avail_out = 4; |
||||
loops = 0; |
||||
|
||||
while ((ret=nsis_decomp(n))==CL_SUCCESS) { |
||||
if (n->nsis.next_out - obuf == 4) break; |
||||
if (++loops > 20) { |
||||
cli_dbgmsg("NSIS: xs looping, breaking out"__AT__"\n"); |
||||
ret = CL_BREAK; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (ret != CL_SUCCESS) { |
||||
cli_dbgmsg("NSIS: bad stream"__AT__"\n"); |
||||
close(n->ofd); |
||||
return CL_EFORMAT; |
||||
} |
||||
|
||||
size=cli_readint32(obuf); |
||||
if (ctx->limits && ctx->limits->maxfilesize && size > ctx->limits->maxfilesize) { |
||||
cli_dbgmsg("NSIS: Breaking out due to filesize limit (%u, max: %lu) in solid archive\n", size, ctx->limits->maxfilesize); |
||||
close(n->ofd); |
||||
return CL_EFORMAT; |
||||
} |
||||
|
||||
n->nsis.next_out = obuf; |
||||
n->nsis.avail_out = MIN(BUFSIZ,size); |
||||
loops = 0; |
||||
|
||||
while (size && (ret=nsis_decomp(n))==CL_SUCCESS) { |
||||
unsigned int wsz; |
||||
if ((wsz = n->nsis.next_out - obuf)) { |
||||
if (cli_writen(n->ofd, obuf, wsz) != (ssize_t) wsz) { |
||||
close(n->ofd); |
||||
return CL_EIO; |
||||
} |
||||
size-=wsz; |
||||
n->nsis.next_out = obuf; |
||||
n->nsis.avail_out = MIN(size,BUFSIZ); |
||||
} else if ( ++loops > 20 ) { |
||||
cli_dbgmsg("NSIS: xs looping, breaking out"__AT__"\n"); |
||||
ret = CL_BREAK; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
if (ret == CL_BREAK) { |
||||
if (cli_writen(n->ofd, obuf, n->nsis.next_out - obuf) != n->nsis.next_out - obuf) { |
||||
close(n->ofd); |
||||
return CL_EIO; |
||||
} |
||||
n->eof=1; |
||||
} else if (ret != CL_SUCCESS) { |
||||
cli_dbgmsg("NSIS: bad stream"__AT__"\n"); |
||||
close(n->ofd); |
||||
return CL_EFORMAT; |
||||
} |
||||
|
||||
return CL_SUCCESS; |
||||
} |
||||
|
||||
} |
||||
|
||||
static uint8_t detcomp(const char *b) { |
||||
if (*b=='1') return COMP_BZIP2; |
||||
if ((cli_readint32(b)&~0x80000000)==0x5d) return COMP_LZMA; |
||||
return COMP_ZLIB; |
||||
} |
||||
|
||||
static int nsis_headers(struct nsis_st *n, cli_ctx *ctx) { |
||||
char buf[28]; |
||||
struct stat st; |
||||
uint32_t pos; |
||||
int i; |
||||
uint8_t comps[] = {0, 0, 0, 0}, trunc = 0; |
||||
|
||||
if (fstat(n->ifd, &st)==-1 || |
||||
lseek(n->ifd, n->off, SEEK_SET)==-1 || |
||||
cli_readn(n->ifd, buf, 28) != 28) |
||||
return CL_EIO; |
||||
|
||||
n->hsz = (uint32_t)cli_readint32(buf+0x14); |
||||
n->asz = (uint32_t)cli_readint32(buf+0x18); |
||||
|
||||
cli_dbgmsg("NSIS: Header info - Flags=%x, Header size=%x, Archive size=%x\n", cli_readint32(buf), n->hsz, n->asz); |
||||
|
||||
if (st.st_size - n->off < (off_t) n->asz) { |
||||
cli_dbgmsg("NSIS: Possibly truncated file\n"); |
||||
n->asz = st.st_size - n->off; |
||||
trunc++; |
||||
} else if (st.st_size - n->off != (off_t) n->asz) { |
||||
cli_dbgmsg("NSIS: Overlays found\n"); |
||||
} |
||||
|
||||
n->asz -= 0x1c; |
||||
|
||||
/* Guess if solid */ |
||||
for (i=0, pos=0;pos < n->asz-4;i++) { |
||||
int32_t nextsz; |
||||
if (cli_readn(n->ifd, buf+4, 4)!=4) return CL_EIO; |
||||
nextsz=cli_readint32(buf+4); |
||||
if (!i) n->comp = detcomp(buf+4); |
||||
if (nextsz&0x80000000) { |
||||
nextsz&=~0x80000000; |
||||
if (cli_readn(n->ifd, buf+4, 4)!=4) return CL_EIO; |
||||
comps[detcomp(buf+4)]++; |
||||
nextsz-=4; |
||||
pos+=4; |
||||
} |
||||
if ((pos+=4+nextsz) > n->asz) { |
||||
n->solid = 1; |
||||
break; |
||||
} |
||||
|
||||
if (lseek(n->ifd, nextsz, SEEK_CUR)==-1) return CL_EIO; |
||||
} |
||||
|
||||
if (trunc && i>=2) n->solid=0; |
||||
|
||||
cli_dbgmsg("NSIS: solid compression%s detected\n", (n->solid)?"":" not"); |
||||
|
||||
/* Guess the compression method */ |
||||
if (!n->solid) { |
||||
cli_dbgmsg("NSIS: bzip2 %u - lzma %u - zlib %u\n", comps[1], comps[2], comps[3]); |
||||
n->comp = (comps[1]<comps[2]) ? (comps[2]<comps[3] ? COMP_ZLIB : COMP_LZMA) : (comps[1]<comps[3] ? COMP_ZLIB : COMP_BZIP2); |
||||
} |
||||
|
||||
if (lseek(n->ifd, n->off+0x1c, SEEK_SET)==-1) return CL_EIO; |
||||
|
||||
return nsis_unpack_next(n, ctx); |
||||
} |
||||
|
||||
|
||||
|
||||
int cli_nsis_unpack(struct nsis_st *n, cli_ctx *ctx) { |
||||
return (n->fno) ? nsis_unpack_next(n, ctx) : nsis_headers(n, ctx); |
||||
} |
||||
|
||||
void cli_nsis_free(struct nsis_st *n) { |
||||
nsis_shutdown(n); |
||||
if (n->solid && n->freeme) free(n->freeme); |
||||
} |
||||
@ -0,0 +1,55 @@ |
||||
/*
|
||||
* Copyright (C) 2007 aCaB <acab@clamav.net> |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License version 2 as |
||||
* published by the Free Software Foundation. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; if not, write to the Free Software |
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
||||
* MA 02110-1301, USA. |
||||
*/ |
||||
|
||||
#ifndef __NSIS_H |
||||
#define __NSIS_H |
||||
|
||||
#include "cltypes.h" |
||||
#include "nsis_bzlib.h" |
||||
#include "LZMADecode.h" |
||||
#include "nsis_zlib.h" |
||||
#include "others.h" |
||||
|
||||
struct nsis_st { |
||||
int ifd; |
||||
int ofd; |
||||
off_t off; |
||||
char *dir; |
||||
uint32_t asz; |
||||
uint32_t hsz; |
||||
uint32_t fno; |
||||
struct { |
||||
uint32_t avail_in; |
||||
unsigned char *next_in; |
||||
uint32_t avail_out; |
||||
unsigned char *next_out; |
||||
} nsis; |
||||
nsis_bzstream bz; |
||||
lzma_stream lz; |
||||
nsis_z_stream z; |
||||
unsigned char *freeme; |
||||
uint8_t comp; |
||||
uint8_t solid; |
||||
uint8_t freecomp; |
||||
uint8_t eof; |
||||
char ofn[1024]; |
||||
}; |
||||
|
||||
int cli_nsis_unpack(struct nsis_st *, cli_ctx *); |
||||
void cli_nsis_free(struct nsis_st *); |
||||
#endif |
||||
Loading…
Reference in new issue