5 #if defined(_MSC_VER) && (_MSC_VER <= 1800)
6 # define _CRT_SECURE_NO_WARNINGS
7 # define snprintf sprintf_s
23 return fwrite(&
i,
sizeof(
i), 1, fp);
27 return fwrite(array, 1, arrayBytes, fp);
31 return fread(
i,
sizeof(*
i), 1, fp);
35 return fread(array, 1, arrayBytes, fp);
50 char*
const inpPtr = inpBuf[inpBufIndex];
59 lz4Stream, inpPtr, cmpBuf, inpBytes,
sizeof(cmpBuf), 1);
64 write_bin(outFp, cmpBuf, (
size_t) cmpBytes);
67 inpBufIndex = (inpBufIndex + 1) % 2;
89 const size_t readCount0 =
read_int(inpFp, &cmpBytes);
90 if(readCount0 != 1 || cmpBytes <= 0) {
94 const size_t readCount1 =
read_bin(inpFp, cmpBuf, (
size_t) cmpBytes);
95 if(readCount1 != (
size_t) cmpBytes) {
101 char*
const decPtr = decBuf[decBufIndex];
103 lz4StreamDecode, cmpBuf, decPtr, cmpBytes,
BLOCK_BYTES);
107 write_bin(outFp, decPtr, (
size_t) decBytes);
110 decBufIndex = (decBufIndex + 1) % 2;
122 const size_t r0 =
read_bin(fp0, b0,
sizeof(b0));
127 if(0 ==
r0 || 0 ==
r1) {
131 result = memcmp(b0,
b1,
r0);
141 char inpFilename[256] = { 0 };
142 char lz4Filename[256] = { 0 };
143 char decFilename[256] = { 0 };
146 printf(
"Please specify input filename\n");
154 printf(
"inp = [%s]\n", inpFilename);
155 printf(
"lz4 = [%s]\n", lz4Filename);
156 printf(
"dec = [%s]\n", decFilename);
160 FILE* inpFp = fopen(inpFilename,
"rb");
161 FILE* outFp = fopen(lz4Filename,
"wb");
163 printf(
"compress : %s -> %s\n", inpFilename, lz4Filename);
165 printf(
"compress : done\n");
173 FILE* inpFp = fopen(lz4Filename,
"rb");
174 FILE* outFp = fopen(decFilename,
"wb");
176 printf(
"decompress : %s -> %s\n", lz4Filename, decFilename);
178 printf(
"decompress : done\n");
186 FILE* inpFp = fopen(inpFilename,
"rb");
187 FILE* decFp = fopen(decFilename,
"rb");
189 printf(
"verify : %s <-> %s\n", inpFilename, decFilename);
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
size_t read_bin(FILE *fp, void *array, size_t arrayBytes)
int main(int argc, char *argv[])
size_t write_int(FILE *fp, int i)
void test_compress(FILE *outFp, FILE *inpFp)
void test_decompress(FILE *outFp, FILE *inpFp)
int compare(FILE *fp0, FILE *fp1)
size_t write_bin(FILE *fp, const void *array, size_t arrayBytes)
size_t read_int(FILE *fp, int *i)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static fork const void static count static fd const char const char static newpath char char argv
LZ4_stream_t * LZ4_initStream(void *buffer, size_t size)
int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize)
LZ4_FORCE_O2 int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *source, char *dest, int compressedSize, int maxOutputSize)
int LZ4_compress_fast_continue(LZ4_stream_t *LZ4_stream, const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
#define LZ4_COMPRESSBOUND(isize)