3 #if defined(_MSC_VER) && (_MSC_VER <= 1800)
4 # define _CRT_SECURE_NO_WARNINGS
5 # define snprintf sprintf_s
14 #define MIN(x, y) ((x) < (y) ? (x) : (y))
31 size_t written = fwrite(&
i,
sizeof(
i), 1, fp);
32 if (written != 1) {
exit(10); }
36 size_t written = fwrite(array, 1, arrayBytes, fp);
37 if (written != arrayBytes) {
exit(11); }
41 size_t read = fread(
i,
sizeof(*
i), 1, fp);
46 size_t read = fread(array, 1, arrayBytes, fp);
47 if (ferror(fp)) {
exit(12); }
63 int *offsetsEnd = offsets;
85 lz4Stream, inpBuf, cmpBuf, inpBytes,
sizeof(cmpBuf), 1);
86 if(cmpBytes <= 0) {
exit(1); }
87 write_bin(outFp, cmpBuf, (
size_t)cmpBytes);
89 *offsetsEnd = *(offsetsEnd - 1) + cmpBytes;
97 while (ptr != offsetsEnd) {
118 if (
length == 0) {
return; }
124 if (
read !=
sizeof(magic)) {
exit(1); }
132 int *offsetsPtr = offsets;
135 if (numOffsets <= endBlock) {
exit(3); }
137 for (block = 0; block <= endBlock; ++block) {
146 for(; currentBlock < endBlock; ++currentBlock) {
149 int cmpBytes = offsets[currentBlock + 1] - offsets[currentBlock];
151 const size_t read =
read_bin(inpFp, cmpBuf, (
size_t)cmpBytes);
152 if(
read != (
size_t)cmpBytes) {
exit(4); }
159 lz4StreamDecode, cmpBuf, decBuf, cmpBytes,
BLOCK_BYTES);
160 if(decBytes <= 0) {
exit(5); }
185 if(0 ==
r0 || 0 ==
r1) {
189 result = memcmp(b0,
b1,
r0);
200 char inpFilename[256] = { 0 };
201 char lz4Filename[256] = { 0 };
202 char decFilename[256] = { 0 };
203 char dictFilename[256] = { 0 };
210 printf(
"Usage: %s input dictionary offset length",
argv[0]);
221 printf(
"inp = [%s]\n", inpFilename);
222 printf(
"lz4 = [%s]\n", lz4Filename);
223 printf(
"dec = [%s]\n", decFilename);
224 printf(
"dict = [%s]\n", dictFilename);
230 FILE* dictFp = fopen(dictFilename,
"rb");
237 FILE* inpFp = fopen(inpFilename,
"rb");
238 FILE* outFp = fopen(lz4Filename,
"wb");
240 printf(
"compress : %s -> %s\n", inpFilename, lz4Filename);
242 printf(
"compress : done\n");
250 FILE* inpFp = fopen(lz4Filename,
"rb");
251 FILE* outFp = fopen(decFilename,
"wb");
253 printf(
"decompress : %s -> %s\n", lz4Filename, decFilename);
255 printf(
"decompress : done\n");
263 FILE* inpFp = fopen(inpFilename,
"rb");
264 FILE* decFp = fopen(decFilename,
"rb");
267 printf(
"verify : %s <-> %s\n", inpFilename, decFilename);
static RzILOpEffect * cmp(cs_insn *insn, bool is_thumb)
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
size_t read_bin(FILE *fp, void *array, size_t arrayBytes)
int main(int argc, char *argv[])
void seek_bin(FILE *fp, long offset, int origin)
void write_int(FILE *fp, int i)
void read_int(FILE *fp, int *i)
void test_compress(FILE *outFp, FILE *inpFp, void *dict, int dictSize)
int compare(FILE *fp0, FILE *fp1, int length)
void write_bin(FILE *fp, const void *array, size_t arrayBytes)
void test_decompress(FILE *outFp, FILE *inpFp, void *dict, int dictSize, int offset, int length)
static static fork const void static count static fd const char const char static newpath char char argv
int LZ4_loadDict(LZ4_stream_t *LZ4_dict, const char *dictionary, int dictSize)
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)
int read(izstream &zs, T *x, Items items)