summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-01-27 20:57:54 -0600
committerAlexandru Gagniuc <mr.nuke.me@gmail.com>2014-01-29 20:06:26 +0100
commit9ad52fe56e8fbb1cd2e37795741773708b72eef3 (patch)
treee0a598de3af23d97add5eca164c2f60f6f55c47a
parent4a7b1152115e866cd3164bdd90d8b0ffa26a863b (diff)
downloadcoreboot-9ad52fe56e8fbb1cd2e37795741773708b72eef3.tar.xz
cbfstool/lzma: Avoid use of typedef with structs and enums
When typedef is used with structs, enums, and to create new typenames, readability suffers. As such, restrict use of typedefs only to creating new data types. The 80 character limit is intentionally ignored in this patch in order to make reviewing easier. Change-Id: I62660b19bccf234128930a047c754bce3ebb6cf8 Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-on: http://review.coreboot.org/5070 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
-rw-r--r--util/cbfstool/lzma/C/LzFind.c74
-rw-r--r--util/cbfstool/lzma/C/LzFind.h40
-rw-r--r--util/cbfstool/lzma/C/LzmaDec.c54
-rw-r--r--util/cbfstool/lzma/C/LzmaDec.h42
-rw-r--r--util/cbfstool/lzma/C/LzmaEnc.c216
-rw-r--r--util/cbfstool/lzma/C/LzmaEnc.h26
-rw-r--r--util/cbfstool/lzma/C/Types.h86
-rw-r--r--util/cbfstool/lzma/lzma.c16
8 files changed, 277 insertions, 277 deletions
diff --git a/util/cbfstool/lzma/C/LzFind.c b/util/cbfstool/lzma/C/LzFind.c
index a0d01bfff2..9d3c694e44 100644
--- a/util/cbfstool/lzma/C/LzFind.c
+++ b/util/cbfstool/lzma/C/LzFind.c
@@ -14,7 +14,7 @@
#define kStartMaxLen 3
-static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
+static void LzInWindow_Free(struct CMatchFinder *p, struct ISzAlloc *alloc)
{
if (!p->directInput)
{
@@ -25,7 +25,7 @@ static void LzInWindow_Free(CMatchFinder *p, ISzAlloc *alloc)
/* keepSizeBefore + keepSizeAfter + keepSizeReserv must be < 4G) */
-static int LzInWindow_Create(CMatchFinder *p, uint32_t keepSizeReserv, ISzAlloc *alloc)
+static int LzInWindow_Create(struct CMatchFinder *p, uint32_t keepSizeReserv, struct ISzAlloc *alloc)
{
uint32_t blockSize = p->keepSizeBefore + p->keepSizeAfter + keepSizeReserv;
if (p->directInput)
@@ -42,19 +42,19 @@ static int LzInWindow_Create(CMatchFinder *p, uint32_t keepSizeReserv, ISzAlloc
return (p->bufferBase != 0);
}
-uint8_t *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
-static uint8_t MatchFinder_GetIndexByte(CMatchFinder *p, int32_t bindex) { return p->buffer[bindex]; }
+uint8_t *MatchFinder_GetPointerToCurrentPos(struct CMatchFinder *p) { return p->buffer; }
+static uint8_t MatchFinder_GetIndexByte(struct CMatchFinder *p, int32_t bindex) { return p->buffer[bindex]; }
-static uint32_t MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
+static uint32_t MatchFinder_GetNumAvailableBytes(struct CMatchFinder *p) { return p->streamPos - p->pos; }
-void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue)
+void MatchFinder_ReduceOffsets(struct CMatchFinder *p, uint32_t subValue)
{
p->posLimit -= subValue;
p->pos -= subValue;
p->streamPos -= subValue;
}
-static void MatchFinder_ReadBlock(CMatchFinder *p)
+static void MatchFinder_ReadBlock(struct CMatchFinder *p)
{
if (p->streamEndWasReached || p->result != SZ_OK)
return;
@@ -89,7 +89,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p)
}
}
-void MatchFinder_MoveBlock(CMatchFinder *p)
+void MatchFinder_MoveBlock(struct CMatchFinder *p)
{
memmove(p->bufferBase,
p->buffer - p->keepSizeBefore,
@@ -97,7 +97,7 @@ void MatchFinder_MoveBlock(CMatchFinder *p)
p->buffer = p->bufferBase + p->keepSizeBefore;
}
-int MatchFinder_NeedMove(CMatchFinder *p)
+int MatchFinder_NeedMove(struct CMatchFinder *p)
{
if (p->directInput)
return 0;
@@ -105,7 +105,7 @@ int MatchFinder_NeedMove(CMatchFinder *p)
return ((size_t)(p->bufferBase + p->blockSize - p->buffer) <= p->keepSizeAfter);
}
-void MatchFinder_ReadIfRequired(CMatchFinder *p)
+void MatchFinder_ReadIfRequired(struct CMatchFinder *p)
{
if (p->streamEndWasReached)
return;
@@ -113,14 +113,14 @@ void MatchFinder_ReadIfRequired(CMatchFinder *p)
MatchFinder_ReadBlock(p);
}
-static void MatchFinder_CheckAndMoveAndRead(CMatchFinder *p)
+static void MatchFinder_CheckAndMoveAndRead(struct CMatchFinder *p)
{
if (MatchFinder_NeedMove(p))
MatchFinder_MoveBlock(p);
MatchFinder_ReadBlock(p);
}
-static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
+static void MatchFinder_SetDefaultSettings(struct CMatchFinder *p)
{
p->cutValue = 32;
p->btMode = 1;
@@ -130,7 +130,7 @@ static void MatchFinder_SetDefaultSettings(CMatchFinder *p)
#define kCrcPoly 0xEDB88320
-void MatchFinder_Construct(CMatchFinder *p)
+void MatchFinder_Construct(struct CMatchFinder *p)
{
uint32_t i;
p->bufferBase = 0;
@@ -148,19 +148,19 @@ void MatchFinder_Construct(CMatchFinder *p)
}
}
-static void MatchFinder_FreeThisClassMemory(CMatchFinder *p, ISzAlloc *alloc)
+static void MatchFinder_FreeThisClassMemory(struct CMatchFinder *p, struct ISzAlloc *alloc)
{
alloc->Free(alloc, p->hash);
p->hash = 0;
}
-void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc)
+void MatchFinder_Free(struct CMatchFinder *p, struct ISzAlloc *alloc)
{
MatchFinder_FreeThisClassMemory(p, alloc);
LzInWindow_Free(p, alloc);
}
-static CLzRef* AllocRefs(uint32_t num, ISzAlloc *alloc)
+static CLzRef* AllocRefs(uint32_t num, struct ISzAlloc *alloc)
{
size_t sizeInuint8_ts = (size_t)num * sizeof(CLzRef);
if (sizeInuint8_ts / sizeof(CLzRef) != num)
@@ -168,9 +168,9 @@ static CLzRef* AllocRefs(uint32_t num, ISzAlloc *alloc)
return (CLzRef *)alloc->Alloc(alloc, sizeInuint8_ts);
}
-int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
+int MatchFinder_Create(struct CMatchFinder *p, uint32_t historySize,
uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
- ISzAlloc *alloc)
+ struct ISzAlloc *alloc)
{
uint32_t sizeReserv;
if (historySize > kMaxHistorySize)
@@ -243,7 +243,7 @@ int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
return 0;
}
-static void MatchFinder_SetLimits(CMatchFinder *p)
+static void MatchFinder_SetLimits(struct CMatchFinder *p)
{
uint32_t limit = kMaxValForNormalize - p->pos;
uint32_t limit2 = p->cyclicBufferSize - p->cyclicBufferPos;
@@ -268,7 +268,7 @@ static void MatchFinder_SetLimits(CMatchFinder *p)
p->posLimit = p->pos + limit;
}
-void MatchFinder_Init(CMatchFinder *p)
+void MatchFinder_Init(struct CMatchFinder *p)
{
uint32_t i;
for (i = 0; i < p->hashSizeSum; i++)
@@ -282,7 +282,7 @@ void MatchFinder_Init(CMatchFinder *p)
MatchFinder_SetLimits(p);
}
-static uint32_t MatchFinder_GetSubValue(CMatchFinder *p)
+static uint32_t MatchFinder_GetSubValue(struct CMatchFinder *p)
{
return (p->pos - p->historySize - 1) & kNormalizeMask;
}
@@ -301,14 +301,14 @@ void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, uint32_t numItems)
}
}
-static void MatchFinder_Normalize(CMatchFinder *p)
+static void MatchFinder_Normalize(struct CMatchFinder *p)
{
uint32_t subValue = MatchFinder_GetSubValue(p);
MatchFinder_Normalize3(subValue, p->hash, p->hashSizeSum + p->numSons);
MatchFinder_ReduceOffsets(p, subValue);
}
-static void MatchFinder_CheckLimits(CMatchFinder *p)
+static void MatchFinder_CheckLimits(struct CMatchFinder *p)
{
if (p->pos == kMaxValForNormalize)
MatchFinder_Normalize(p);
@@ -462,7 +462,7 @@ static void SkipMatchesSpec(uint32_t lenLimit, uint32_t curMatch, uint32_t pos,
#define MOVE_POS_RET MOVE_POS return offset;
-static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
+static void MatchFinder_MovePos(struct CMatchFinder *p) { MOVE_POS; }
#define GET_MATCHES_HEADER2(minLen, ret_op) \
uint32_t lenLimit; uint32_t hashValue; const uint8_t *cur; uint32_t curMatch; \
@@ -481,7 +481,7 @@ static void MatchFinder_MovePos(CMatchFinder *p) { MOVE_POS; }
#define SKIP_FOOTER \
SkipMatchesSpec(lenLimit, curMatch, MF_PARAMS(p)); MOVE_POS;
-static uint32_t Bt2_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
+static uint32_t Bt2_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances)
{
uint32_t offset;
GET_MATCHES_HEADER(2)
@@ -492,7 +492,7 @@ static uint32_t Bt2_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
GET_MATCHES_FOOTER(offset, 1)
}
-uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
+uint32_t Bt3Zip_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances)
{
uint32_t offset;
GET_MATCHES_HEADER(3)
@@ -503,7 +503,7 @@ uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
GET_MATCHES_FOOTER(offset, 2)
}
-static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
+static uint32_t Bt3_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances)
{
uint32_t hash2Value, delta2, maxLen, offset;
GET_MATCHES_HEADER(3)
@@ -536,7 +536,7 @@ static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
GET_MATCHES_FOOTER(offset, maxLen)
}
-static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
+static uint32_t Bt4_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances)
{
uint32_t hash2Value, hash3Value, delta2, delta3, maxLen, offset;
GET_MATCHES_HEADER(4)
@@ -583,7 +583,7 @@ static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
GET_MATCHES_FOOTER(offset, maxLen)
}
-static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
+static uint32_t Hc4_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances)
{
uint32_t hash2Value, hash3Value, delta2, delta3, maxLen, offset;
GET_MATCHES_HEADER(4)
@@ -632,7 +632,7 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
MOVE_POS_RET
}
-uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
+uint32_t Hc3Zip_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances)
{
uint32_t offset;
GET_MATCHES_HEADER(3)
@@ -644,7 +644,7 @@ uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances)
MOVE_POS_RET
}
-static void Bt2_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
+static void Bt2_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num)
{
do
{
@@ -657,7 +657,7 @@ static void Bt2_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
while (--num != 0);
}
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
+void Bt3Zip_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num)
{
do
{
@@ -670,7 +670,7 @@ void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
while (--num != 0);
}
-static void Bt3_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
+static void Bt3_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num)
{
do
{
@@ -685,7 +685,7 @@ static void Bt3_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
while (--num != 0);
}
-static void Bt4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
+static void Bt4_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num)
{
do
{
@@ -701,7 +701,7 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
while (--num != 0);
}
-static void Hc4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
+static void Hc4_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num)
{
do
{
@@ -718,7 +718,7 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
while (--num != 0);
}
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
+void Hc3Zip_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num)
{
do
{
@@ -732,7 +732,7 @@ void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num)
while (--num != 0);
}
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable)
+void MatchFinder_CreateVTable(struct CMatchFinder *p, struct IMatchFinder *vTable)
{
vTable->Init = (Mf_Init_Func)MatchFinder_Init;
vTable->GetIndexByte = (Mf_GetIndexByte_Func)MatchFinder_GetIndexByte;
diff --git a/util/cbfstool/lzma/C/LzFind.h b/util/cbfstool/lzma/C/LzFind.h
index 696203291c..66e1ecdf32 100644
--- a/util/cbfstool/lzma/C/LzFind.h
+++ b/util/cbfstool/lzma/C/LzFind.h
@@ -8,7 +8,7 @@
typedef uint32_t CLzRef;
-typedef struct _CMatchFinder
+struct CMatchFinder
{
uint8_t *buffer;
uint32_t pos;
@@ -26,7 +26,7 @@ typedef struct _CMatchFinder
uint32_t cutValue;
uint8_t *bufferBase;
- ISeqInStream *stream;
+ struct ISeqInStream *stream;
int streamEndWasReached;
uint32_t blockSize;
@@ -44,30 +44,30 @@ typedef struct _CMatchFinder
uint32_t numSons;
SRes result;
uint32_t crc[256];
-} CMatchFinder;
+};
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(int32_t)(index)])
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
-int MatchFinder_NeedMove(CMatchFinder *p);
-uint8_t *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
-void MatchFinder_MoveBlock(CMatchFinder *p);
-void MatchFinder_ReadIfRequired(CMatchFinder *p);
+int MatchFinder_NeedMove(struct CMatchFinder *p);
+uint8_t *MatchFinder_GetPointerToCurrentPos(struct CMatchFinder *p);
+void MatchFinder_MoveBlock(struct CMatchFinder *p);
+void MatchFinder_ReadIfRequired(struct CMatchFinder *p);
-void MatchFinder_Construct(CMatchFinder *p);
+void MatchFinder_Construct(struct CMatchFinder *p);
/* Conditions:
historySize <= 3 GB
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
*/
-int MatchFinder_Create(CMatchFinder *p, uint32_t historySize,
+int MatchFinder_Create(struct CMatchFinder *p, uint32_t historySize,
uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter,
- ISzAlloc *alloc);
-void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
+ struct ISzAlloc *alloc);
+void MatchFinder_Free(struct CMatchFinder *p, struct ISzAlloc *alloc);
void MatchFinder_Normalize3(uint32_t subValue, CLzRef *items, uint32_t numItems);
-void MatchFinder_ReduceOffsets(CMatchFinder *p, uint32_t subValue);
+void MatchFinder_ReduceOffsets(struct CMatchFinder *p, uint32_t subValue);
uint32_t * GetMatchesSpec1(uint32_t lenLimit, uint32_t curMatch, uint32_t pos, const uint8_t *buffer, CLzRef *son,
uint32_t _cyclicBufferPos, uint32_t _cyclicBufferSize, uint32_t _cutValue,
@@ -86,7 +86,7 @@ typedef const uint8_t * (*Mf_GetPointerToCurrentPos_Func)(void *object);
typedef uint32_t (*Mf_GetMatches_Func)(void *object, uint32_t *distances);
typedef void (*Mf_Skip_Func)(void *object, uint32_t);
-typedef struct _IMatchFinder
+struct IMatchFinder
{
Mf_Init_Func Init;
Mf_GetIndexByte_Func GetIndexByte;
@@ -94,14 +94,14 @@ typedef struct _IMatchFinder
Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
Mf_GetMatches_Func GetMatches;
Mf_Skip_Func Skip;
-} IMatchFinder;
+};
-void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
+void MatchFinder_CreateVTable(struct CMatchFinder *p, struct IMatchFinder *vTable);
-void MatchFinder_Init(CMatchFinder *p);
-uint32_t Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances);
-uint32_t Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances);
-void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num);
-void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, uint32_t num);
+void MatchFinder_Init(struct CMatchFinder *p);
+uint32_t Bt3Zip_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances);
+uint32_t Hc3Zip_MatchFinder_GetMatches(struct CMatchFinder *p, uint32_t *distances);
+void Bt3Zip_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num);
+void Hc3Zip_MatchFinder_Skip(struct CMatchFinder *p, uint32_t num);
#endif
diff --git a/util/cbfstool/lzma/C/LzmaDec.c b/util/cbfstool/lzma/C/LzmaDec.c
index af55858988..5537b712ba 100644
--- a/util/cbfstool/lzma/C/LzmaDec.c
+++ b/util/cbfstool/lzma/C/LzmaDec.c
@@ -128,7 +128,7 @@ Out:
= kMatchSpecLenStart + 2 : State Init Marker
*/
-static int LzmaDec_DecodeReal(CLzmaDec *p, size_t limit_parm, const uint8_t *bufLimit)
+static int LzmaDec_DecodeReal(struct CLzmaDec *p, size_t limit_parm, const uint8_t *bufLimit)
{
CLzmaProb *probs = p->probs;
@@ -425,7 +425,7 @@ static int LzmaDec_DecodeReal(CLzmaDec *p, size_t limit_parm, const uint8_t *buf
return SZ_OK;
}
-static void LzmaDec_WriteRem(CLzmaDec *p, size_t limit)
+static void LzmaDec_WriteRem(struct CLzmaDec *p, size_t limit)
{
if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart)
{
@@ -451,7 +451,7 @@ static void LzmaDec_WriteRem(CLzmaDec *p, size_t limit)
}
}
-static int LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimit)
+static int LzmaDec_DecodeReal2(struct CLzmaDec *p, size_t limit, const uint8_t *bufLimit)
{
do
{
@@ -476,22 +476,22 @@ static int LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimi
return 0;
}
-typedef enum
+enum ELzmaDummy
{
DUMMY_ERROR, /* unexpected end of input stream */
DUMMY_LIT,
DUMMY_MATCH,
DUMMY_REP
-} ELzmaDummy;
+};
-static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t inSize)
+static enum ELzmaDummy LzmaDec_TryDummy(const struct CLzmaDec *p, const uint8_t *buf, size_t inSize)
{
uint32_t range = p->range;
uint32_t code = p->code;
const uint8_t *bufLimit = buf + inSize;
CLzmaProb *probs = p->probs;
unsigned state = p->state;
- ELzmaDummy res;
+ enum ELzmaDummy res;
{
CLzmaProb *prob;
@@ -675,14 +675,14 @@ static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t
}
-static void LzmaDec_InitRc(CLzmaDec *p, const uint8_t *data)
+static void LzmaDec_InitRc(struct CLzmaDec *p, const uint8_t *data)
{
p->code = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]);
p->range = 0xFFFFFFFF;
p->needFlush = 0;
}
-static void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState)
+static void LzmaDec_InitDicAndState(struct CLzmaDec *p, bool initDic, bool initState)
{
p->needFlush = 1;
p->remainLen = 0;
@@ -698,13 +698,13 @@ static void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState)
p->needInitState = 1;
}
-void LzmaDec_Init(CLzmaDec *p)
+void LzmaDec_Init(struct CLzmaDec *p)
{
p->dicPos = 0;
LzmaDec_InitDicAndState(p, true, true);
}
-static void LzmaDec_InitStateReal(CLzmaDec *p)
+static void LzmaDec_InitStateReal(struct CLzmaDec *p)
{
uint32_t numProbs = Literal + ((uint32_t)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp));
uint32_t i;
@@ -716,8 +716,8 @@ static void LzmaDec_InitStateReal(CLzmaDec *p)
p->needInitState = 0;
}
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen,
- ELzmaFinishMode finishMode, ELzmaStatus *status)
+SRes LzmaDec_DecodeToDic(struct CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen,
+ enum ELzmaFinishMode finishMode, enum ELzmaStatus *status)
{
size_t inSize = *srcLen;
(*srcLen) = 0;
@@ -837,7 +837,7 @@ SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_
return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA;
}
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status)
+SRes LzmaDec_DecodeToBuf(struct CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, enum ELzmaFinishMode finishMode, enum ELzmaStatus *status)
{
size_t outSize = *destLen;
size_t inSize = *srcLen;
@@ -845,7 +845,7 @@ SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint
for (;;)
{
size_t inSizeCur = inSize, outSizeCur, dicPos;
- ELzmaFinishMode curFinishMode;
+ enum ELzmaFinishMode curFinishMode;
SRes res;
if (p->dicPos == p->dicBufSize)
p->dicPos = 0;
@@ -877,25 +877,25 @@ SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint
}
}
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc)
+void LzmaDec_FreeProbs(struct CLzmaDec *p, struct ISzAlloc *alloc)
{
alloc->Free(alloc, p->probs);
p->probs = 0;
}
-static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc)
+static void LzmaDec_FreeDict(struct CLzmaDec *p, struct ISzAlloc *alloc)
{
alloc->Free(alloc, p->dic);
p->dic = 0;
}
-void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc)
+void LzmaDec_Free(struct CLzmaDec *p, struct ISzAlloc *alloc)
{
LzmaDec_FreeProbs(p, alloc);
LzmaDec_FreeDict(p, alloc);
}
-SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size)
+SRes LzmaProps_Decode(struct CLzmaProps *p, const uint8_t *data, unsigned size)
{
uint32_t dicSize;
uint8_t d;
@@ -921,7 +921,7 @@ SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size)
return SZ_OK;
}
-static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc)
+static SRes LzmaDec_AllocateProbs2(struct CLzmaDec *p, const struct CLzmaProps *propNew, struct ISzAlloc *alloc)
{
uint32_t numProbs = LzmaProps_GetNumProbs(propNew);
if (p->probs == 0 || numProbs != p->numProbs)
@@ -935,18 +935,18 @@ static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAl
return SZ_OK;
}
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc)
+SRes LzmaDec_AllocateProbs(struct CLzmaDec *p, const uint8_t *props, unsigned propsSize, struct ISzAlloc *alloc)
{
- CLzmaProps propNew;
+ struct CLzmaProps propNew;
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
p->prop = propNew;
return SZ_OK;
}
-SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc)
+SRes LzmaDec_Allocate(struct CLzmaDec *p, const uint8_t *props, unsigned propsSize, struct ISzAlloc *alloc)
{
- CLzmaProps propNew;
+ struct CLzmaProps propNew;
size_t dicBufSize;
RINOK(LzmaProps_Decode(&propNew, props, propsSize));
RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc));
@@ -967,10 +967,10 @@ SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISz
}
SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen,
- const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode,
- ELzmaStatus *status, ISzAlloc *alloc)
+ const uint8_t *propData, unsigned propSize, enum ELzmaFinishMode finishMode,
+ enum ELzmaStatus *status, struct ISzAlloc *alloc)
{
- CLzmaDec p;
+ struct CLzmaDec p;
SRes res;
size_t inSize = *srcLen;
size_t outSize = *destLen;
diff --git a/util/cbfstool/lzma/C/LzmaDec.h b/util/cbfstool/lzma/C/LzmaDec.h
index a38a71434f..d296f85b03 100644
--- a/util/cbfstool/lzma/C/LzmaDec.h
+++ b/util/cbfstool/lzma/C/LzmaDec.h
@@ -21,11 +21,11 @@
#define LZMA_PROPS_SIZE 5
-typedef struct _CLzmaProps
+struct CLzmaProps
{
unsigned lc, lp, pb;
uint32_t dicSize;
-} CLzmaProps;
+};
/* LzmaProps_Decode - decodes properties
Returns:
@@ -33,7 +33,7 @@ Returns:
SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
-SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size);
+SRes LzmaProps_Decode(struct CLzmaProps *p, const uint8_t *data, unsigned size);
/* ---------- LZMA Decoder state ---------- */
@@ -43,9 +43,9 @@ SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size);
#define LZMA_REQUIRED_INPUT_MAX 20
-typedef struct
+struct CLzmaDec
{
- CLzmaProps prop;
+ struct CLzmaProps prop;
CLzmaProb *probs;
uint8_t *dic;
const uint8_t *buf;
@@ -62,21 +62,21 @@ typedef struct
uint32_t numProbs;
unsigned tempBufSize;
uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX];
-} CLzmaDec;
+};
#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
-void LzmaDec_Init(CLzmaDec *p);
+void LzmaDec_Init(struct CLzmaDec *p);
/* There are two types of LZMA streams:
0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
-typedef enum
+enum ELzmaFinishMode
{
LZMA_FINISH_ANY, /* finish at any point */
LZMA_FINISH_END /* block must be finished at the end */
-} ELzmaFinishMode;
+};
/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
@@ -93,14 +93,14 @@ typedef enum
3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
You must use correct finish mode in that case. */
-typedef enum
+enum ELzmaStatus
{
LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
-} ELzmaStatus;
+};
/* ELzmaStatus is used only as output value for function call */
@@ -127,11 +127,11 @@ LzmaDec_Allocate* can return:
SZ_ERROR_UNSUPPORTED - Unsupported properties
*/
-SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc);
-void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc);
+SRes LzmaDec_AllocateProbs(struct CLzmaDec *p, const uint8_t *props, unsigned propsSize, struct ISzAlloc *alloc);
+void LzmaDec_FreeProbs(struct CLzmaDec *p, struct ISzAlloc *alloc);
-SRes LzmaDec_Allocate(CLzmaDec *state, const uint8_t *prop, unsigned propsSize, ISzAlloc *alloc);
-void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
+SRes LzmaDec_Allocate(struct CLzmaDec *state, const uint8_t *prop, unsigned propsSize, struct ISzAlloc *alloc);
+void LzmaDec_Free(struct CLzmaDec *state, struct ISzAlloc *alloc);
/* ---------- Dictionary Interface ---------- */
@@ -174,8 +174,8 @@ Returns:
SZ_ERROR_DATA - Data error
*/
-SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit,
- const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+SRes LzmaDec_DecodeToDic(struct CLzmaDec *p, size_t dicLimit,
+ const uint8_t *src, size_t *srcLen, enum ELzmaFinishMode finishMode, enum ELzmaStatus *status);
/* ---------- Buffer Interface ---------- */
@@ -191,8 +191,8 @@ finishMode:
LZMA_FINISH_END - Stream must be finished after (*destLen).
*/
-SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen,
- const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
+SRes LzmaDec_DecodeToBuf(struct CLzmaDec *p, uint8_t *dest, size_t *destLen,
+ const uint8_t *src, size_t *srcLen, enum ELzmaFinishMode finishMode, enum ELzmaStatus *status);
/* ---------- One Call Interface ---------- */
@@ -217,7 +217,7 @@ Returns:
*/
SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen,
- const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode,
- ELzmaStatus *status, ISzAlloc *alloc);
+ const uint8_t *propData, unsigned propSize, enum ELzmaFinishMode finishMode,
+ enum ELzmaStatus *status, struct ISzAlloc *alloc);
#endif
diff --git a/util/cbfstool/lzma/C/LzmaEnc.c b/util/cbfstool/lzma/C/LzmaEnc.c
index 83012d8a07..9b18b19688 100644
--- a/util/cbfstool/lzma/C/LzmaEnc.c
+++ b/util/cbfstool/lzma/C/LzmaEnc.c
@@ -42,7 +42,7 @@ static int ttt = 0;
#define kNumBitPriceShiftBits 4
#define kBitPrice (1 << kNumBitPriceShiftBits)
-void LzmaEncProps_Init(CLzmaEncProps *p)
+void LzmaEncProps_Init(struct CLzmaEncProps *p)
{
p->level = 5;
p->dictSize = p->mc = 0;
@@ -50,7 +50,7 @@ void LzmaEncProps_Init(CLzmaEncProps *p)
p->writeEndMark = 0;
}
-void LzmaEncProps_Normalize(CLzmaEncProps *p)
+void LzmaEncProps_Normalize(struct CLzmaEncProps *p)
{
int level = p->level;
if (level < 0) level = 5;
@@ -73,9 +73,9 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
#endif
}
-uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2)
+uint32_t LzmaEncProps_GetDictSize(const struct CLzmaEncProps *props2)
{
- CLzmaEncProps props = *props2;
+ struct CLzmaEncProps props = *props2;
LzmaEncProps_Normalize(&props);
return props.dictSize;
}
@@ -139,7 +139,7 @@ static void LzmaEnc_FastPosInit(uint8_t *g_FastPos)
typedef unsigned CState;
-typedef struct
+struct COptimal
{
uint32_t price;
@@ -153,7 +153,7 @@ typedef struct
uint32_t posPrev;
uint32_t backPrev;
uint32_t backs[LZMA_NUM_REPS];
-} COptimal;
+};
#define kNumOpts (1 << 12)
@@ -201,24 +201,24 @@ typedef struct
#define kNumStates 12
-typedef struct
+struct CLenEnc
{
CLzmaProb choice;
CLzmaProb choice2;
CLzmaProb low[LZMA_NUM_PB_STATES_MAX << kLenNumLowBits];
CLzmaProb mid[LZMA_NUM_PB_STATES_MAX << kLenNumMidBits];
CLzmaProb high[kLenNumHighSymbols];
-} CLenEnc;
+};
-typedef struct
+struct CLenPriceEnc
{
- CLenEnc p;
+ struct CLenEnc p;
uint32_t prices[LZMA_NUM_PB_STATES_MAX][kLenNumSymbolsTotal];
uint32_t tableSize;
uint32_t counters[LZMA_NUM_PB_STATES_MAX];
-} CLenPriceEnc;
+};
-typedef struct
+struct CRangeEnc
{
uint32_t range;
uint8_t cache;
@@ -227,12 +227,12 @@ typedef struct
uint8_t *buf;
uint8_t *bufLim;
uint8_t *bufBase;
- ISeqOutStream *outStream;
+ struct ISeqOutStream *outStream;
uint64_t processed;
SRes res;
-} CRangeEnc;
+};
-typedef struct
+struct CSaveState
{
CLzmaProb *litProbs;
@@ -247,16 +247,16 @@ typedef struct
CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
CLzmaProb posAlignEncoder[1 << kNumAlignBits];
- CLenPriceEnc lenEnc;
- CLenPriceEnc repLenEnc;
+ struct CLenPriceEnc lenEnc;
+ struct CLenPriceEnc repLenEnc;
uint32_t reps[LZMA_NUM_REPS];
uint32_t state;
-} CSaveState;
+};
-typedef struct
+struct CLzmaEnc
{
- IMatchFinder matchFinder;
+ struct IMatchFinder matchFinder;
void *matchFinderObj;
#ifndef _7ZIP_ST
@@ -264,7 +264,7 @@ typedef struct
CMatchFinderMt matchFinderMt;
#endif
- CMatchFinder matchFinderBase;
+ struct CMatchFinder matchFinderBase;
#ifndef _7ZIP_ST
uint8_t pad[128];
@@ -276,7 +276,7 @@ typedef struct
uint32_t longestMatchLength;
uint32_t numPairs;
uint32_t numAvail;
- COptimal opt[kNumOpts];
+ struct COptimal opt[kNumOpts];
#ifndef LZMA_LOG_BSR
uint8_t g_FastPos[1 << kNumLogBits];
@@ -312,14 +312,14 @@ typedef struct
CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex];
CLzmaProb posAlignEncoder[1 << kNumAlignBits];
- CLenPriceEnc lenEnc;
- CLenPriceEnc repLenEnc;
+ struct CLenPriceEnc lenEnc;
+ struct CLenPriceEnc repLenEnc;
unsigned lclp;
bool fastMode;
- CRangeEnc rc;
+ struct CRangeEnc rc;
bool writeEndMark;
uint64_t nowPos64;
@@ -333,8 +333,8 @@ typedef struct
int needInit;
- CSaveState saveState;
-} CLzmaEnc;
+ struct CSaveState saveState;
+};
/*static void LzmaEnc_SaveState(CLzmaEncHandle pp)
{
@@ -388,10 +388,10 @@ typedef struct
memcpy(dest->litProbs, p->litProbs, (0x300 << dest->lclp) * sizeof(CLzmaProb));
}*/
-SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const CLzmaEncProps *props2)
+SRes LzmaEnc_SetProps(CLzmaEncHandle pp, const struct CLzmaEncProps *props2)
{
- CLzmaEnc *p = (CLzmaEnc *)pp;
- CLzmaEncProps props = *props2;
+ struct CLzmaEnc *p = (struct CLzmaEnc *)pp;
+ struct CLzmaEncProps props = *props2;
LzmaEncProps_Normalize(&props);
if (props.lc > LZMA_LC_MAX || props.lp > LZMA_LP_MAX || props.pb > LZMA_PB_MAX ||
@@ -453,7 +453,7 @@ static const int kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11,
#define kInfinityPrice (1 << 30)
-static void RangeEnc_Construct(CRangeEnc *p)
+static void RangeEnc_Construct(struct CRangeEnc *p)
{
p->outStream = 0;
p->bufBase = 0;
@@ -462,7 +462,7 @@ static void RangeEnc_Construct(CRangeEnc *p)
#define RangeEnc_GetProcessed(p) ((p)->processed + ((p)->buf - (p)->bufBase) + (p)->cacheSize)
#define RC_BUF_SIZE (1 << 16)
-static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
+static int RangeEnc_Alloc(struct CRangeEnc *p, struct ISzAlloc *alloc)
{
if (p->bufBase == 0)
{
@@ -474,13 +474,13 @@ static int RangeEnc_Alloc(CRangeEnc *p, ISzAlloc *alloc)
return 1;
}
-static void RangeEnc_Free(CRangeEnc *p, ISzAlloc *alloc)
+static void RangeEnc_Free(struct CRangeEnc *p, struct ISzAlloc *alloc)
{
alloc->Free(alloc, p->bufBase);
p->bufBase = 0;
}
-static void RangeEnc_Init(CRangeEnc *p)
+static void RangeEnc_Init(struct CRangeEnc *p)
{
/* Stream.Init(); */
p->low = 0;
@@ -494,7 +494,7 @@ static void RangeEnc_Init(CRangeEnc *p)
p->res = SZ_OK;
}
-static void RangeEnc_FlushStream(CRangeEnc *p)
+static void RangeEnc_FlushStream(struct CRangeEnc *p)
{
size_t num;
if (p->res != SZ_OK)
@@ -506,7 +506,7 @@ static void RangeEnc_FlushStream(CRangeEnc *p)
p->buf = p->bufBase;
}
-static void RangeEnc_ShiftLow(CRangeEnc *p)
+static void RangeEnc_ShiftLow(struct CRangeEnc *p)
{
if ((uint32_t)p->low < (uint32_t)0xFF000000 || (int)(p->low >> 32) != 0)
{
@@ -527,14 +527,14 @@ static void RangeEnc_ShiftLow(CRangeEnc *p)
p->low = (uint32_t)p->low << 8;
}
-static void RangeEnc_FlushData(CRangeEnc *p)
+static void RangeEnc_FlushData(struct CRangeEnc *p)
{
int i;
for (i = 0; i < 5; i++)
RangeEnc_ShiftLow(p);
}
-static void RangeEnc_EncodeDirectBits(CRangeEnc *p, uint32_t value, int numBits)
+static void RangeEnc_EncodeDirectBits(struct CRangeEnc *p, uint32_t value, int numBits)
{
do
{
@@ -549,7 +549,7 @@ static void RangeEnc_EncodeDirectBits(CRangeEnc *p, uint32_t value, int numBits)
while (numBits != 0);
}
-static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, uint32_t symbol)
+static void RangeEnc_EncodeBit(struct CRangeEnc *p, CLzmaProb *prob, uint32_t symbol)
{
uint32_t ttt = *prob;
uint32_t newBound = (p->range >> kNumBitModelTotalBits) * ttt;
@@ -572,7 +572,7 @@ static void RangeEnc_EncodeBit(CRangeEnc *p, CLzmaProb *prob, uint32_t symbol)
}
}
-static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, uint32_t symbol)
+static void LitEnc_Encode(struct CRangeEnc *p, CLzmaProb *probs, uint32_t symbol)
{
symbol |= 0x100;
do
@@ -583,7 +583,7 @@ static void LitEnc_Encode(CRangeEnc *p, CLzmaProb *probs, uint32_t symbol)
while (symbol < 0x10000);
}
-static void LitEnc_EncodeMatched(CRangeEnc *p, CLzmaProb *probs, uint32_t symbol, uint32_t matchuint8_t)
+static void LitEnc_EncodeMatched(struct CRangeEnc *p, CLzmaProb *probs, uint32_t symbol, uint32_t matchuint8_t)
{
uint32_t offs = 0x100;
symbol |= 0x100;
@@ -663,7 +663,7 @@ static uint32_t LitEnc_GetPriceMatched(const CLzmaProb *probs, uint32_t symbol,
}
-static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, uint32_t symbol)
+static void RcTree_Encode(struct CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, uint32_t symbol)
{
uint32_t m = 1;
int i;
@@ -677,7 +677,7 @@ static void RcTree_Encode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, uin
}
}
-static void RcTree_ReverseEncode(CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, uint32_t symbol)
+static void RcTree_ReverseEncode(struct CRangeEnc *rc, CLzmaProb *probs, int numBitLevels, uint32_t symbol)
{
uint32_t m = 1;
int i;
@@ -718,7 +718,7 @@ static uint32_t RcTree_ReverseGetPrice(const CLzmaProb *probs, int numBitLevels,
}
-static void LenEnc_Init(CLenEnc *p)
+static void LenEnc_Init(struct CLenEnc *p)
{
unsigned i;
p->choice = p->choice2 = kProbInitValue;
@@ -730,7 +730,7 @@ static void LenEnc_Init(CLenEnc *p)
p->high[i] = kProbInitValue;
}
-static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, uint32_t symbol, uint32_t posState)
+static void LenEnc_Encode(struct CLenEnc *p, struct CRangeEnc *rc, uint32_t symbol, uint32_t posState)
{
if (symbol < kLenNumLowSymbols)
{
@@ -753,7 +753,7 @@ static void LenEnc_Encode(CLenEnc *p, CRangeEnc *rc, uint32_t symbol, uint32_t p
}
}
-static void LenEnc_SetPrices(CLenEnc *p, uint32_t posState, uint32_t numSymbols, uint32_t *prices, uint32_t *ProbPrices)
+static void LenEnc_SetPrices(struct CLenEnc *p, uint32_t posState, uint32_t numSymbols, uint32_t *prices, uint32_t *ProbPrices)
{
uint32_t a0 = GET_PRICE_0a(p->choice);
uint32_t a1 = GET_PRICE_1a(p->choice);
@@ -776,20 +776,20 @@ static void LenEnc_SetPrices(CLenEnc *p, uint32_t posState, uint32_t numSymbols,
prices[i] = b1 + RcTree_GetPrice(p->high, kLenNumHighBits, i - kLenNumLowSymbols - kLenNumMidSymbols, ProbPrices);
}
-static void LenPriceEnc_UpdateTable(CLenPriceEnc *p, uint32_t posState, uint32_t *ProbPrices)
+static void LenPriceEnc_UpdateTable(struct CLenPriceEnc *p, uint32_t posState, uint32_t *ProbPrices)
{
LenEnc_SetPrices(&p->p, posState, p->tableSize, p->prices[posState], ProbPrices);
p->counters[posState] = p->tableSize;
}
-static void LenPriceEnc_UpdateTables(CLenPriceEnc *p, uint32_t numPosStates, uint32_t *ProbPrices)
+static void LenPriceEnc_UpdateTables(struct CLenPriceEnc *p, uint32_t numPosStates, uint32_t *ProbPrices)
{
uint32_t posState;
for (posState = 0; posState < numPosStates; posState++)
LenPriceEnc_UpdateTable(p, posState, ProbPrices);
}
-static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, uint32_t symbol, uint32_t posState, bool updatePrice, uint32_t *ProbPrices)
+static void LenEnc_Encode2(struct CLenPriceEnc *p, struct CRangeEnc *rc, uint32_t symbol, uint32_t posState, bool updatePrice, uint32_t *ProbPrices)
{
LenEnc_Encode(&p->p, rc, symbol, posState);
if (updatePrice)
@@ -800,7 +800,7 @@ static void LenEnc_Encode2(CLenPriceEnc *p, CRangeEnc *rc, uint32_t symbol, uint
-static void MovePos(CLzmaEnc *p, uint32_t num)
+static void MovePos(struct CLzmaEnc *p, uint32_t num)
{
#ifdef SHOW_STAT
ttt += num;
@@ -813,7 +813,7 @@ static void MovePos(CLzmaEnc *p, uint32_t num)
}
}
-static uint32_t ReadMatchDistances(CLzmaEnc *p, uint32_t *numDistancePairsRes)
+static uint32_t ReadMatchDistances(struct CLzmaEnc *p, uint32_t *numDistancePairsRes)
{
uint32_t lenRes = 0, numPairs;
p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
@@ -853,14 +853,14 @@ static uint32_t ReadMatchDistances(CLzmaEnc *p, uint32_t *numDistancePairsRes)
#define MakeAsShortRep(p) (p)->backPrev = 0; (p)->prev1IsChar = false;
#define IsShortRep(p) ((p)->backPrev == 0)
-static uint32_t GetRepLen1Price(CLzmaEnc *p, uint32_t state, uint32_t posState)
+static uint32_t GetRepLen1Price(struct CLzmaEnc *p, uint32_t state, uint32_t posState)
{
return
GET_PRICE_0(p->isRepG0[state]) +
GET_PRICE_0(p->isRep0Long[state][posState]);
}
-static uint32_t GetPureRepPrice(CLzmaEnc *p, uint32_t repIndex, uint32_t state, uint32_t posState)
+static uint32_t GetPureRepPrice(struct CLzmaEnc *p, uint32_t repIndex, uint32_t state, uint32_t posState)
{
uint32_t price;
if (repIndex == 0)
@@ -882,13 +882,13 @@ static uint32_t GetPureRepPrice(CLzmaEnc *p, uint32_t repIndex, uint32_t state,
return price;
}
-static uint32_t GetRepPrice(CLzmaEnc *p, uint32_t repIndex, uint32_t len, uint32_t state, uint32_t posState)
+static uint32_t GetRepPrice(struct CLzmaEnc *p, uint32_t repIndex, uint32_t len, uint32_t state, uint32_t posState)
{
return p->repLenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN] +
GetPureRepPrice(p, repIndex, state, posState);
}
-static uint32_t Backward(CLzmaEnc *p, uint32_t *backRes, uint32_t cur)
+static uint32_t Backward(struct CLzmaEnc *p, uint32_t *backRes, uint32_t cur)
{
uint32_t posMem = p->opt[cur].posPrev;
uint32_t backMem = p->opt[cur].backPrev;
@@ -926,7 +926,7 @@ static uint32_t Backward(CLzmaEnc *p, uint32_t *backRes, uint32_t cur)
#define LIT_PROBS(pos, prevuint8_t) (p->litProbs + ((((pos) & p->lpMask) << p->lc) + ((prevuint8_t) >> (8 - p->lc))) * 0x300)
-static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
+static uint32_t GetOptimum(struct CLzmaEnc *p, uint32_t position, uint32_t *backRes)
{
uint32_t numAvail, mainLen, numPairs, repMaxIndex, i, posState, lenEnd, len, cur;
uint32_t matchPrice, repMatchPrice, normalMatchPrice;
@@ -936,7 +936,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
uint8_t curuint8_t, matchuint8_t;
if (p->optimumEndIndex != p->optimumCurrentIndex)
{
- const COptimal *opt = &p->opt[p->optimumCurrentIndex];
+ const struct COptimal *opt = &p->opt[p->optimumCurrentIndex];
uint32_t lenRes = opt->posPrev - p->optimumCurrentIndex;
*backRes = opt->backPrev;
p->optimumCurrentIndex = opt->posPrev;
@@ -1057,7 +1057,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
do
{
uint32_t curAndLenPrice = price + p->repLenEnc.prices[posState][repLen - 2];
- COptimal *opt = &p->opt[repLen];
+ struct COptimal *opt = &p->opt[repLen];
if (curAndLenPrice < opt->price)
{
opt->price = curAndLenPrice;
@@ -1079,7 +1079,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
offs += 2;
for (; ; len++)
{
- COptimal *opt;
+ struct COptimal *opt;
uint32_t distance = matches[offs + 1];
uint32_t curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][len - LZMA_MATCH_LEN_MIN];
@@ -1128,8 +1128,8 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
bool nextIsChar;
uint8_t curuint8_t, matchuint8_t;
const uint8_t *data;
- COptimal *curOpt;
- COptimal *nextOpt;
+ struct COptimal *curOpt;
+ struct COptimal *nextOpt;
cur++;
if (cur == lenEnd)
@@ -1172,7 +1172,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
else
{
uint32_t pos;
- const COptimal *prevOpt;
+ const struct COptimal *prevOpt;
if (curOpt->prev1IsChar && curOpt->prev2)
{
posPrev = curOpt->posPrev2;
@@ -1286,7 +1286,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
/* for (; lenTest2 >= 2; lenTest2--) */
{
uint32_t curAndLenPrice;
- COptimal *opt;
+ struct COptimal *opt;
uint32_t offset = cur + 1 + lenTest2;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
@@ -1323,7 +1323,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
do
{
uint32_t curAndLenPrice = price + p->repLenEnc.prices[posState][lenTest - 2];
- COptimal *opt = &p->opt[cur + lenTest];
+ struct COptimal *opt = &p->opt[cur + lenTest];
if (curAndLenPrice < opt->price)
{
opt->price = curAndLenPrice;
@@ -1365,7 +1365,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
/* for (; lenTest2 >= 2; lenTest2--) */
{
uint32_t curAndLenPrice;
- COptimal *opt;
+ struct COptimal *opt;
uint32_t offset = cur + lenTest + 1 + lenTest2;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
@@ -1411,7 +1411,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
{
uint32_t curAndLenPrice = normalMatchPrice + p->lenEnc.prices[posState][lenTest - LZMA_MATCH_LEN_MIN];
uint32_t lenToPosState = GetLenToPosState(lenTest);
- COptimal *opt;
+ struct COptimal *opt;
if (curBack < kNumFullDistances)
curAndLenPrice += p->distancesPrices[lenToPosState][curBack];
else
@@ -1455,7 +1455,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
{
uint32_t offset = cur + lenTest + 1 + lenTest2;
uint32_t curAndLenPrice;
- COptimal *opt;
+ struct COptimal *opt;
while (lenEnd < offset)
p->opt[++lenEnd].price = kInfinityPrice;
curAndLenPrice = nextRepMatchPrice + GetRepPrice(p, 0, lenTest2, state2, posStateNext);
@@ -1486,7 +1486,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes)
#define ChangePair(smallDist, bigDist) (((bigDist) >> 7) > (smallDist))
-static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes)
+static uint32_t GetOptimumFast(struct CLzmaEnc *p, uint32_t *backRes)
{
uint32_t numAvail, mainLen, mainDist, numPairs, repIndex, repLen, i;
const uint8_t *data;
@@ -1594,7 +1594,7 @@ static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes)
return mainLen;
}
-static void WriteEndMarker(CLzmaEnc *p, uint32_t posState)
+static void WriteEndMarker(struct CLzmaEnc *p, uint32_t posState)
{
uint32_t len;
RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
@@ -1607,7 +1607,7 @@ static void WriteEndMarker(CLzmaEnc *p, uint32_t posState)
RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
}
-static SRes CheckErrors(CLzmaEnc *p)
+static SRes CheckErrors(struct CLzmaEnc *p)
{
if (p->result != SZ_OK)
return p->result;
@@ -1620,7 +1620,7 @@ static SRes CheckErrors(CLzmaEnc *p)
return p->result;
}
-static SRes Flush(CLzmaEnc *p, uint32_t nowPos)
+static SRes Flush(struct CLzmaEnc *p, uint32_t nowPos)
{
/* ReleaseMFStream(); */
p->finished = true;
@@ -1631,7 +1631,7 @@ static SRes Flush(CLzmaEnc *p, uint32_t nowPos)
return CheckErrors(p);
}
-static void FillAlignPrices(CLzmaEnc *p)
+static void FillAlignPrices(struct CLzmaEnc *p)
{
uint32_t i;
for (i = 0; i < kAlignTableSize; i++)
@@ -1639,7 +1639,7 @@ static void FillAlignPrices(CLzmaEnc *p)
p->alignPriceCount = 0;
}
-static void FillDistancesPrices(CLzmaEnc *p)
+static void FillDistancesPrices(struct CLzmaEnc *p)
{
uint32_t tempPrices[kNumFullDistances];
uint32_t i, lenToPosState;
@@ -1673,7 +1673,7 @@ static void FillDistancesPrices(CLzmaEnc *p)
p->matchPriceCount = 0;
}
-static void LzmaEnc_Construct(CLzmaEnc *p)
+static void LzmaEnc_Construct(struct CLzmaEnc *p)
{
RangeEnc_Construct(&p->rc);
MatchFinder_Construct(&p->matchFinderBase);
@@ -1683,7 +1683,7 @@ static void LzmaEnc_Construct(CLzmaEnc *p)
#endif
{
- CLzmaEncProps props;
+ struct CLzmaEncProps props;
LzmaEncProps_Init(&props);
LzmaEnc_SetProps(p, &props);
}
@@ -1697,16 +1697,16 @@ static void LzmaEnc_Construct(CLzmaEnc *p)
p->saveState.litProbs = 0;
}
-CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc)
+CLzmaEncHandle LzmaEnc_Create(struct ISzAlloc *alloc)
{
void *p;
- p = alloc->Alloc(alloc, sizeof(CLzmaEnc));
+ p = alloc->Alloc(alloc, sizeof(struct CLzmaEnc));
if (p != 0)
- LzmaEnc_Construct((CLzmaEnc *)p);
+ LzmaEnc_Construct((struct CLzmaEnc *)p);
return p;
}
-static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
+static void LzmaEnc_FreeLits(struct CLzmaEnc *p, struct ISzAlloc *alloc)
{
alloc->Free(alloc, p->litProbs);
alloc->Free(alloc, p->saveState.litProbs);
@@ -1714,7 +1714,7 @@ static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
p->saveState.litProbs = 0;
}
-static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
+static void LzmaEnc_Destruct(struct CLzmaEnc *p, struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
#ifndef _7ZIP_ST
MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
@@ -1724,13 +1724,13 @@ static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
RangeEnc_Free(&p->rc, alloc);
}
-void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig)
+void LzmaEnc_Destroy(CLzmaEncHandle p, struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
- LzmaEnc_Destruct((CLzmaEnc *)p, alloc, allocBig);
+ LzmaEnc_Destruct((struct CLzmaEnc *)p, alloc, allocBig);
alloc->Free(alloc, p);
}
-static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, bool useLimits, uint32_t maxPackSize, uint32_t maxUnpackSize)
+static SRes LzmaEnc_CodeOneBlock(struct CLzmaEnc *p, bool useLimits, uint32_t maxPackSize, uint32_t maxUnpackSize)
{
uint32_t nowPos32, startPos32;
if (p->needInit)
@@ -1894,7 +1894,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, bool useLimits, uint32_t maxPackSi
#define kBigHashDicLimit ((uint32_t)1 << 24)
-static SRes LzmaEnc_Alloc(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+static SRes LzmaEnc_Alloc(struct CLzmaEnc *p, uint32_t keepWindowSize, struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
uint32_t beforeSize = kNumOpts;
#ifndef _7ZIP_ST
@@ -1946,7 +1946,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc,
return SZ_OK;
}
-static void LzmaEnc_Init(CLzmaEnc *p)
+static void LzmaEnc_Init(struct CLzmaEnc *p)
{
uint32_t i;
p->state = 0;
@@ -2004,7 +2004,7 @@ static void LzmaEnc_Init(CLzmaEnc *p)
p->lpMask = (1 << p->lp) - 1;
}
-static void LzmaEnc_InitPrices(CLzmaEnc *p)
+static void LzmaEnc_InitPrices(struct CLzmaEnc *p)
{
if (!p->fastMode)
{
@@ -2019,7 +2019,7 @@ static void LzmaEnc_InitPrices(CLzmaEnc *p)
LenPriceEnc_UpdateTables(&p->repLenEnc, 1 << p->pb, p->ProbPrices);
}
-static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+static SRes LzmaEnc_AllocAndInit(struct CLzmaEnc *p, uint32_t keepWindowSize, struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
uint32_t i;
for (i = 0; i < (uint32_t)kDicLogSizeMaxCompress; i++)
@@ -2036,10 +2036,10 @@ static SRes LzmaEnc_AllocAndInit(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc
return SZ_OK;
}
-static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream,
- ISzAlloc *alloc, ISzAlloc *allocBig)
+static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, struct ISeqOutStream *outStream, struct ISeqInStream *inStream,
+ struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
- CLzmaEnc *p = (CLzmaEnc *)pp;
+ struct CLzmaEnc *p = (struct CLzmaEnc *)pp;
p->matchFinderBase.stream = inStream;
p->needInit = 1;
p->rc.outStream = outStream;
@@ -2056,7 +2056,7 @@ static SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInS
return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
}*/
-static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const uint8_t *src, size_t srcLen)
+static void LzmaEnc_SetInputBuf(struct CLzmaEnc *p, const uint8_t *src, size_t srcLen)
{
p->matchFinderBase.directInput = 1;
p->matchFinderBase.bufferBase = (uint8_t *)src;
@@ -2064,9 +2064,9 @@ static void LzmaEnc_SetInputBuf(CLzmaEnc *p, const uint8_t *src, size_t srcLen)
}
static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const uint8_t *src, size_t srcLen,
- uint32_t keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
+ uint32_t keepWindowSize, struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
- CLzmaEnc *p = (CLzmaEnc *)pp;
+ struct CLzmaEnc *p = (struct CLzmaEnc *)pp;
LzmaEnc_SetInputBuf(p, src, srcLen);
p->needInit = 1;
@@ -2084,17 +2084,17 @@ static void LzmaEnc_Finish(CLzmaEncHandle pp)
#endif
}
-typedef struct
+struct CSeqOutStreamBuf
{
- ISeqOutStream funcTable;
+ struct ISeqOutStream funcTable;
uint8_t *data;
size_t rem;
bool overflow;
-} CSeqOutStreamBuf;
+};
static size_t MyWrite(void *pp, const void *data, size_t size)
{
- CSeqOutStreamBuf *p = (CSeqOutStreamBuf *)pp;
+ struct CSeqOutStreamBuf *p = (struct CSeqOutStreamBuf *)pp;
if (p->rem < size)
{
size = p->rem;
@@ -2153,7 +2153,7 @@ static size_t MyWrite(void *pp, const void *data, size_t size)
return res;
}*/
-static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
+static SRes LzmaEnc_Encode2(struct CLzmaEnc *p, struct ICompressProgress *progress)
{
SRes res = SZ_OK;
@@ -2183,16 +2183,16 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress)
return res;
}
-SRes LzmaEnc_Encode(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ICompressProgress *progress,
- ISzAlloc *alloc, ISzAlloc *allocBig)
+SRes LzmaEnc_Encode(CLzmaEncHandle pp, struct ISeqOutStream *outStream, struct ISeqInStream *inStream, struct ICompressProgress *progress,
+ struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
RINOK(LzmaEnc_Prepare(pp, outStream, inStream, alloc, allocBig));
- return LzmaEnc_Encode2((CLzmaEnc *)pp, progress);
+ return LzmaEnc_Encode2((struct CLzmaEnc *)pp, progress);
}
SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, uint8_t *props, size_t *size)
{
- CLzmaEnc *p = (CLzmaEnc *)pp;
+ struct CLzmaEnc *p = (struct CLzmaEnc *)pp;
int i;
uint32_t dictSize = p->dictSize;
if (*size < LZMA_PROPS_SIZE)
@@ -2220,12 +2220,12 @@ SRes LzmaEnc_WriteProperties(CLzmaEncHandle pp, uint8_t *props, size_t *size)
}
SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
- int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
+ int writeEndMark, struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
SRes res;
- CLzmaEnc *p = (CLzmaEnc *)pp;
+ struct CLzmaEnc *p = (struct CLzmaEnc *)pp;
- CSeqOutStreamBuf outStream;
+ struct CSeqOutStreamBuf outStream;
LzmaEnc_SetInputBuf(p, src, srcLen);
@@ -2248,10 +2248,10 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, uint8_t *dest, size_t *destLen, const
}
SRes LzmaEncode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
- const CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize, int writeEndMark,
- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
+ const struct CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize, int writeEndMark,
+ struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig)
{
- CLzmaEnc *p = (CLzmaEnc *)LzmaEnc_Create(alloc);
+ struct CLzmaEnc *p = (struct CLzmaEnc *)LzmaEnc_Create(alloc);
SRes res;
if (p == 0)
return SZ_ERROR_MEM;
diff --git a/util/cbfstool/lzma/C/LzmaEnc.h b/util/cbfstool/lzma/C/LzmaEnc.h
index 376baf2b38..e62bdb33f4 100644
--- a/util/cbfstool/lzma/C/LzmaEnc.h
+++ b/util/cbfstool/lzma/C/LzmaEnc.h
@@ -8,7 +8,7 @@
#define LZMA_PROPS_SIZE 5
-typedef struct _CLzmaEncProps
+struct CLzmaEncProps
{
int level; /* 0 <= level <= 9 */
uint32_t dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
@@ -24,11 +24,11 @@ typedef struct _CLzmaEncProps
uint32_t mc; /* 1 <= mc <= (1 << 30), default = 32 */
unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
int numThreads; /* 1 or 2, default = 2 */
-} CLzmaEncProps;
+};
-void LzmaEncProps_Init(CLzmaEncProps *p);
-void LzmaEncProps_Normalize(CLzmaEncProps *p);
-uint32_t LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
+void LzmaEncProps_Init(struct CLzmaEncProps *p);
+void LzmaEncProps_Normalize(struct CLzmaEncProps *p);
+uint32_t LzmaEncProps_GetDictSize(const struct CLzmaEncProps *props2);
/* ---------- CLzmaEncHandle Interface ---------- */
@@ -45,14 +45,14 @@ Returns:
typedef void * CLzmaEncHandle;
-CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
-void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
-SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
+CLzmaEncHandle LzmaEnc_Create(struct ISzAlloc *alloc);
+void LzmaEnc_Destroy(CLzmaEncHandle p, struct ISzAlloc *alloc, struct ISzAlloc *allocBig);
+SRes LzmaEnc_SetProps(CLzmaEncHandle p, const struct CLzmaEncProps *props);
SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, uint8_t *properties, size_t *size);
-SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+SRes LzmaEnc_Encode(CLzmaEncHandle p, struct ISeqOutStream *outStream, struct ISeqInStream *inStream,
+ struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig);
SRes LzmaEnc_MemEncode(CLzmaEncHandle p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
- int writeEndMark, ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+ int writeEndMark, struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig);
/* ---------- One Call Interface ---------- */
@@ -66,7 +66,7 @@ Return code:
*/
SRes LzmaEncode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t srcLen,
- const CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize, int writeEndMark,
- ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
+ const struct CLzmaEncProps *props, uint8_t *propsEncoded, size_t *propsSize, int writeEndMark,
+ struct ICompressProgress *progress, struct ISzAlloc *alloc, struct ISzAlloc *allocBig);
#endif
diff --git a/util/cbfstool/lzma/C/Types.h b/util/cbfstool/lzma/C/Types.h
index e655f32013..ce98ab5e4f 100644
--- a/util/cbfstool/lzma/C/Types.h
+++ b/util/cbfstool/lzma/C/Types.h
@@ -36,49 +36,49 @@ typedef int WRes; /* This was DWORD for _WIN32. That's uint32_t */
/* The following interfaces use first parameter as pointer to structure */
-typedef struct
+struct IByteIn
{
uint8_t (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
-} IByteIn;
+};
-typedef struct
+struct IByteOut
{
void (*Write)(void *p, uint8_t b);
-} IByteOut;
+};
-typedef struct ISeqInStream
+struct ISeqInStream
{
SRes (*Read)(void *p, void *buf, size_t *size);
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
(output(*size) < input(*size)) is allowed */
-} ISeqInStream;
+};
/* it can return SZ_ERROR_INPUT_EOF */
-SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
-SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
-SRes SeqInStream_ReadByte(ISeqInStream *stream, uint8_t *buf);
+SRes SeqInStream_Read(struct ISeqInStream *stream, void *buf, size_t size);
+SRes SeqInStream_Read2(struct ISeqInStream *stream, void *buf, size_t size, SRes errorType);
+SRes SeqInStream_ReadByte(struct ISeqInStream *stream, uint8_t *buf);
-typedef struct ISeqOutStream
+struct ISeqOutStream
{
size_t (*Write)(void *p, const void *buf, size_t size);
/* Returns: result - the number of actually written bytes.
(result < size) means error */
-} ISeqOutStream;
+};
-typedef enum
+enum ESzSeek
{
SZ_SEEK_SET = 0,
SZ_SEEK_CUR = 1,
SZ_SEEK_END = 2
-} ESzSeek;
+};
-typedef struct
+struct ISeekInStream
{
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
- SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin);
-} ISeekInStream;
+ SRes (*Seek)(void *p, int64_t *pos, enum ESzSeek origin);
+};
-typedef struct
+struct ILookInStream
{
SRes (*Look)(void *p, const void **buf, size_t *size);
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
@@ -89,58 +89,58 @@ typedef struct
SRes (*Read)(void *p, void *buf, size_t *size);
/* reads directly (without buffer). It's same as ISeqInStream::Read */
- SRes (*Seek)(void *p, int64_t *pos, ESzSeek origin);
-} ILookInStream;
+ SRes (*Seek)(void *p, int64_t *pos, enum ESzSeek origin);
+};
-SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
-SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset);
+SRes LookInStream_LookRead(struct ILookInStream *stream, void *buf, size_t *size);
+SRes LookInStream_SeekTo(struct ILookInStream *stream, uint64_t offset);
/* reads via ILookInStream::Read */
-SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
-SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
+SRes LookInStream_Read2(struct ILookInStream *stream, void *buf, size_t size, SRes errorType);
+SRes LookInStream_Read(struct ILookInStream *stream, void *buf, size_t size);
#define LookToRead_BUF_SIZE (1 << 14)
-typedef struct
+struct CLookToRead
{
- ILookInStream s;
- ISeekInStream *realStream;
+ struct ILookInStream s;
+ struct ISeekInStream *realStream;
size_t pos;
size_t size;
uint8_t buf[LookToRead_BUF_SIZE];
-} CLookToRead;
+};
-void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
-void LookToRead_Init(CLookToRead *p);
+void LookToRead_CreateVTable(struct CLookToRead *p, int lookahead);
+void LookToRead_Init(struct CLookToRead *p);
-typedef struct
+struct CSecToLook
{
- ISeqInStream s;
- ILookInStream *realStream;
-} CSecToLook;
+ struct ISeqInStream s;
+ struct ILookInStream *realStream;
+};
-void SecToLook_CreateVTable(CSecToLook *p);
+void SecToLook_CreateVTable(struct CSecToLook *p);
-typedef struct
+struct CSecToRead
{
- ISeqInStream s;
- ILookInStream *realStream;
-} CSecToRead;
+ struct ISeqInStream s;
+ struct ILookInStream *realStream;
+};
-void SecToRead_CreateVTable(CSecToRead *p);
+void SecToRead_CreateVTable(struct CSecToRead *p);
-typedef struct
+struct ICompressProgress
{
SRes (*Progress)(void *p, uint64_t inSize, uint64_t outSize);
/* Returns: result. (result != SZ_OK) means break.
Value (uint64_t)(int64_t)-1 for size means unknown value. */
-} ICompressProgress;
+};
-typedef struct
+struct ISzAlloc
{
void *(*Alloc)(void *p, size_t size);
void (*Free)(void *p, void *address); /* address can be 0 */
-} ISzAlloc;
+};
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
#define IAlloc_Free(p, a) (p)->Free((p), a)
diff --git a/util/cbfstool/lzma/lzma.c b/util/cbfstool/lzma/lzma.c
index f889946690..5eebc7e60c 100644
--- a/util/cbfstool/lzma/lzma.c
+++ b/util/cbfstool/lzma/lzma.c
@@ -57,17 +57,17 @@ static void SzFree(void *unused, void *address)
free(address);
}
-static ISzAlloc LZMAalloc = { SzAlloc, SzFree };
+static struct ISzAlloc LZMAalloc = { SzAlloc, SzFree };
/* Streaming API */
-typedef struct {
+struct vector_t {
char *p;
size_t pos;
size_t size;
-} vector_t;
+};
-static vector_t instream, outstream;
+static struct vector_t instream, outstream;
static SRes Read(void *unused, void *buf, size_t *size)
{
@@ -87,8 +87,8 @@ static size_t Write(void *unused, const void *buf, size_t size)
return size;
}
-static ISeqInStream is = { Read };
-static ISeqOutStream os = { Write };
+static struct ISeqInStream is = { Read };
+static struct ISeqOutStream os = { Write };
/**
* Compress a buffer with lzma
@@ -106,7 +106,7 @@ void do_lzma_compress(char *in, int in_len, char *out, int *out_len)
return;
}
- CLzmaEncProps props;
+ struct CLzmaEncProps props;
LzmaEncProps_Init(&props);
props.dictSize = in_len;
props.pb = 0; /* PosStateBits, default: 2, range: 0..4 */
@@ -181,7 +181,7 @@ void do_lzma_uncompress(char *dst, int dst_len, char *src, int src_len)
return;
}
- ELzmaStatus status;
+ enum ELzmaStatus status;
size_t destlen = out_sizemax;
size_t srclen = src_len - (LZMA_PROPS_SIZE + 8);