📄 lzma.cpp
字号:
#include "vxWorks.h"#include "time.h"#include "semLib.h"#include "taskLib.h"#include "intLib.h"#include "memLib.h"#include "iv.h"#include "string.h"#include "stdio.h"#include "ioLib.h"#include "ftpLib.h"#include "msgQLib.h"#include "sysLib.h"#include <stdio.h>#include "Decoder.h"extern "C" unsigned int SPARC_Decode(unsigned char *data, unsigned int size){ unsigned int i; unsigned int src; unsigned int dest; for(i = 0; i + 4 <= size; i += 4) { if( data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00 || data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0) { src = ((unsigned int)data[i + 0] << 24) | ((unsigned int)data[i + 1] << 16) | ((unsigned int)data[i + 2] << 8) | ((unsigned int)data[i + 3]); src <<= 2; dest = src - i; dest >>= 2; dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; data[i + 0] = (unsigned char)(dest >> 24); data[i + 1] = (unsigned char)(dest >> 16); data[i + 2] = (unsigned char)(dest >> 8); data[i + 3] = (unsigned char)dest; } } return i;}extern "C" unsigned int lzma_decode(unsigned char *src, unsigned char *dest, unsigned int src_length, unsigned char* memBlock){ BYTE properties[5]; WORD i; DWORD outSize = 0; //BYTE *memBlock = NULL; CDecoder decoder; int memSize; DWORD compressedSize = src_length - 13; /////////////////////////// // properties for (i = 0; i < sizeof(properties); i++) { properties[i] = src[i]; } /////////////////////////// // outSize outSize = src[5]; outSize += (DWORD) src[6] << 8; outSize += (DWORD) src[7] << 16; outSize += (DWORD) src[8] << 24; //printf("output bin size is %d bytes \n", outSize); /////////////////////////// // Data //memBlock = (BYTE *) malloc(1 << 20); memSize = decoder.Create(memBlock, properties) - memBlock; memSize += sizeof(decoder); // memSize conatains how many bytes it uses. // change limit for performance checking if (!decoder.Code(src + 13, dest, compressedSize, (UINT32) outSize)) return 0; //printf("Running SPARC_Decode\n"); //SPARC_Decode(dest, outSize); //free(memBlock); return outSize;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -