8 #if defined(_MSC_VER) && (_MSC_VER <= 1800)
9 # define _CRT_SECURE_NO_WARNINGS
10 # define snprintf sprintf_s
13 #define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
15 # pragma GCC diagnostic ignored "-Wmissing-braces"
39 return fwrite(&
i,
sizeof(
i), 1, fp);
44 return fwrite(array, 1, (
size_t)arrayBytes, fp);
48 return fread(
i,
sizeof(*
i), 1, fp);
53 return fread(array, 1, (
size_t)arrayBytes, fp);
67 char*
const inpPtr = &inpBuf[inpOffset];
69 const int inpBytes = (
int)
read_bin(inpFp, inpPtr, randomLength);
70 if (0 == inpBytes)
break;
72 #define CMPBUFSIZE (LZ4_COMPRESSBOUND(MESSAGE_MAX_BYTES))
76 if(cmpBytes <= 0)
break;
80 inpOffset += inpBytes;
105 if(
r0 != 1 || cmpBytes <= 0)
109 if(
r1 != (
size_t) cmpBytes)
113 {
char*
const decPtr = &decBuf[decOffset];
119 decOffset += decBytes;
140 const size_t r0 = fread(b0, 1,
sizeof(b0),
f0);
141 const size_t r1 = fread(
b1, 1,
sizeof(
b1),
f1);
143 if ((
r0==0) && (
r1==0))
return 0;
146 size_t smallest =
r0;
152 if (memcmp(b0,
b1,
r0)) {
153 unsigned errorPos = 0;
154 while ((errorPos <
r0) && (b0[errorPos]==
b1[errorPos])) errorPos++;
159 result +=
sizeof(b0);
168 char inpFilename[256] = { 0 };
169 char lz4Filename[256] = { 0 };
170 char decFilename[256] = { 0 };
176 printf(
"Please specify input filename\n");
180 if (!strcmp(
argv[1],
"-p")) { pause = 1; fileID = 2; }
183 snprintf(lz4Filename, 256,
"%s.lz4s-%d",
argv[fileID], 9);
184 snprintf(decFilename, 256,
"%s.lz4s-%d.dec",
argv[fileID], 9);
186 printf(
"input = [%s]\n", inpFilename);
187 printf(
"lz4 = [%s]\n", lz4Filename);
188 printf(
"decoded = [%s]\n", decFilename);
191 {
FILE*
const inpFp = fopen(inpFilename,
"rb");
192 FILE*
const outFp = fopen(lz4Filename,
"wb");
201 {
FILE*
const inpFp = fopen(lz4Filename,
"rb");
202 FILE*
const outFp = fopen(decFilename,
"wb");
211 {
FILE*
const inpFp = fopen(inpFilename,
"rb");
212 FILE*
const decFp = fopen(decFilename,
"rb");
218 printf(
"Verify : NG : error at pos %u\n", (
unsigned)
cmp-1);
227 printf(
"Press enter to continue ...\n");
228 unused = getchar(); (void)unused;
int main(int argc, const char **argv)
size_t write_int32(FILE *fp, int32_t i)
void test_compress(FILE *outFp, FILE *inpFp)
void test_decompress(FILE *outFp, FILE *inpFp)
size_t compare(FILE *f0, FILE *f1)
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)
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
_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_HC_continue(LZ4_streamHC_t *LZ4_streamHCPtr, const char *src, char *dst, int srcSize, int dstCapacity)
assert(limit<=UINT32_MAX/2)