8 #if defined(_MSC_VER) && (_MSC_VER <= 1800)
9 # define _CRT_SECURE_NO_WARNINGS
10 # define snprintf sprintf_s
32 return fwrite(&
i,
sizeof(
i), 1, fp);
36 return fwrite(array, 1, arrayBytes, fp);
40 return fread(
i,
sizeof(*
i), 1, fp);
44 return fread(array, 1, arrayBytes, fp);
58 char*
const inpPtr = &inpBuf[inpOffset];
60 const int inpBytes = (
int)
read_bin(inpFp, inpPtr, randomLength);
61 if (0 == inpBytes)
break;
64 #define CMPBUFSIZE (LZ4_COMPRESSBOUND(MESSAGE_MAX_BYTES))
67 if(cmpBytes <= 0)
break;
71 inpOffset += inpBytes;
94 if(
r0 != 1 || cmpBytes <= 0)
break;
96 const size_t r1 =
read_bin(inpFp, cmpBuf, cmpBytes);
97 if(
r1 != (
size_t) cmpBytes)
break;
100 {
char*
const decPtr = &decBuf[decOffset];
103 if(decBytes <= 0)
break;
104 decOffset += decBytes;
118 while (0 == result) {
121 const size_t r0 = fread(b0, 1,
sizeof(b0),
f0);
122 const size_t r1 = fread(
b1, 1,
sizeof(
b1),
f1);
126 if (0 ==
r0 || 0 ==
r1)
break;
128 if (0 == result) result = memcmp(b0,
b1,
r0);
137 char inpFilename[256] = { 0 };
138 char lz4Filename[256] = { 0 };
139 char decFilename[256] = { 0 };
142 printf(
"Please specify input filename\n");
148 snprintf(decFilename, 256,
"%s.lz4s-%d.dec",
argv[1], 0);
150 printf(
"inp = [%s]\n", inpFilename);
151 printf(
"lz4 = [%s]\n", lz4Filename);
152 printf(
"dec = [%s]\n", decFilename);
155 {
FILE*
const inpFp = fopen(inpFilename,
"rb");
156 FILE*
const outFp = fopen(lz4Filename,
"wb");
165 {
FILE*
const inpFp = fopen(lz4Filename,
"rb");
166 FILE*
const outFp = fopen(decFilename,
"wb");
175 {
FILE*
const inpFp = fopen(inpFilename,
"rb");
176 FILE*
const decFp = fopen(decFilename,
"rb");
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
int compare(FILE *f0, FILE *f1)
size_t write_int32(FILE *fp, int32_t i)
int main(int argc, char **argv)
void test_compress(FILE *outFp, FILE *inpFp)
void test_decompress(FILE *outFp, FILE *inpFp)
size_t write_bin(FILE *fp, const void *array, int arrayBytes)
size_t read_int32(FILE *fp, int32_t *i)
size_t read_bin(FILE *fp, void *array, int arrayBytes)
_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_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)