38 # pragma warning(disable : 4127)
40 #if defined(__MINGW32__) && !defined(_POSIX_SOURCE)
41 # define _POSIX_SOURCE 1
54 #include <sys/types.h>
58 #define LZ4F_STATIC_LINKING_ONLY
76 #define MAGICNUMBER_SIZE 4
77 #define LZ4IO_MAGICNUMBER 0x184D2204
78 #define LZ4IO_SKIPPABLE0 0x184D2A50
79 #define LZ4IO_SKIPPABLEMASK 0xFFFFFFF0
80 #define LEGACY_MAGICNUMBER 0x184C2102
83 #define LEGACY_BLOCKSIZE (8 MB)
84 #define MIN_STREAM_BUFSIZE (192 KB)
85 #define LZ4IO_BLOCKSIZEID_DEFAULT 7
86 #define LZ4_MAX_DICT_SIZE (64 KB)
92 #define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
93 #define DISPLAYOUT(...) fprintf(stdout, __VA_ARGS__)
94 #define DISPLAYLEVEL(l, ...) if (g_displayLevel>=l) { DISPLAY(__VA_ARGS__); }
97 #define DISPLAYUPDATE(l, ...) if (g_displayLevel>=l) { \
98 if ( ((clock() - g_time) > refreshRate) \
99 || (g_displayLevel>=4) ) { \
101 DISPLAY(__VA_ARGS__); \
102 if (g_displayLevel>=4) fflush(stderr); \
106 #define LZ4IO_STATIC_ASSERT(c) { enum { LZ4IO_static_assert = 1/(int)(!!(c)) }; }
136 #define DEBUGOUTPUT(...) if (DEBUG) DISPLAY(__VA_ARGS__);
137 #define EXM_THROW(error, ...) \
139 DEBUGOUTPUT("Error defined at %s, line %i : \n", __FILE__, __LINE__); \
140 DISPLAYLEVEL(1, "Error %i : ", error); \
141 DISPLAYLEVEL(1, __VA_ARGS__); \
142 DISPLAYLEVEL(1, " \n"); \
150 #define EXTENDED_ARGUMENTS
151 #define EXTENDED_HELP
152 #define EXTENDED_FORMAT
153 #define DEFAULT_DECOMPRESSOR LZ4IO_decompressLZ4F
163 if (!ret)
EXM_THROW(21,
"Allocation error : not enough memory");
219 static const size_t blockSizeTable[] = { 64
KB, 256
KB, 1
MB, 4
MB };
220 static const unsigned minBlockSizeID = 4;
221 static const unsigned maxBlockSizeID = 7;
222 if ((bsid < minBlockSizeID) || (bsid > maxBlockSizeID))
return 0;
230 static const size_t minBlockSize = 32;
231 static const size_t maxBlockSize = 4
MB;
233 if (blockSize < minBlockSize) blockSize = minBlockSize;
234 if (blockSize > maxBlockSize) blockSize = maxBlockSize;
238 while (blockSize >>= 2)
240 if (bsid < 7) bsid = 7;
321 f = fopen(srcFileName,
"rb");
342 DISPLAYLEVEL(4,
"Sparse File Support automatically disabled on stdout ;"
343 " to force-enable it, add --sparse command \n");
347 FILE*
const testf = fopen( dstFileName,
"rb" );
351 DISPLAY(
"%s already exists; not overwritten \n", dstFileName);
354 DISPLAY(
"%s already exists; do you wish to overwrite (y/N) ? ", dstFileName);
355 {
int ch = getchar();
356 if ((ch!=
'Y') && (ch!=
'y')) {
357 DISPLAY(
" not overwritten \n");
360 while ((ch!=EOF) && (ch!=
'\n')) ch = getchar();
362 f = fopen( dstFileName,
"wb" );
383 unsigned char*
const dstPtr = (
unsigned char*)
p;
384 dstPtr[0] = (
unsigned char)value32;
385 dstPtr[1] = (
unsigned char)(value32 >> 8);
386 dstPtr[2] = (
unsigned char)(value32 >> 16);
387 dstPtr[3] = (
unsigned char)(value32 >> 24);
402 typedef int (*compress_f)(
const char*
src,
char*
dst,
int srcSize,
int dstSize,
int cLevel);
404 unsigned long long filesize = 0;
414 clock_t const clockStart = clock();
416 EXM_THROW(20,
"%s : open file error ", input_filename);
419 if (foutput ==
NULL) {
421 EXM_THROW(20,
"%s : open file error ", input_filename);
426 out_buff = (
char*)
malloc((
size_t)outBuffSize + 4);
427 if (!in_buff || !out_buff)
428 EXM_THROW(21,
"Allocation error : not enough memory");
433 EXM_THROW(22,
"Write error : cannot write header");
439 size_t const inSize = fread(in_buff, (
size_t)1, (
size_t)
LEGACY_BLOCKSIZE, finput);
440 if (inSize == 0)
break;
445 outSize = compressionFunction(in_buff, out_buff+4, (
int)inSize, outBuffSize, compressionlevel);
447 compressedfilesize += (
unsigned long long)outSize+4;
449 (
int)(filesize>>20), (
double)compressedfilesize/filesize*100);
453 assert(outSize < outBuffSize);
455 if (fwrite(out_buff, 1, (
size_t)outSize+4, foutput) != (
size_t)(outSize+4)) {
456 EXM_THROW(24,
"Write error : cannot write compressed block");
458 if (ferror(finput))
EXM_THROW(25,
"Error while reading %s ", input_filename);
462 if (clockEnd==clockStart) clockEnd+=1;
463 filesize += !filesize;
465 DISPLAYLEVEL(2,
"Compressed %llu bytes into %llu bytes ==> %.2f%%\n",
466 filesize, compressedfilesize, (
double)compressedfilesize / filesize * 100);
467 {
double const seconds = (double)(clockEnd - clockStart) / CLOCKS_PER_SEC;
468 DISPLAYLEVEL(4,
"Done in %.2f s ==> %.2f MB/s\n", seconds,
469 (
double)filesize / seconds / 1024 / 1024);
476 if (strcmp(output_filename,
stdoutmark)) fclose(foutput);
486 const char** inFileNamesTable,
int ifntSize,
491 int missed_files = 0;
494 const size_t suffixSize = strlen(
suffix);
496 if (dstFileName ==
NULL)
return ifntSize;
499 for (
i=0;
i<ifntSize;
i++) {
500 size_t const ifnSize = strlen(inFileNamesTable[
i]);
508 if (ofnSize <= ifnSize+suffixSize+1) {
510 ofnSize = ifnSize + 20;
511 dstFileName = (
char*)
malloc(ofnSize);
512 if (dstFileName==
NULL) {
515 strcpy(dstFileName, inFileNamesTable[
i]);
516 strcat(dstFileName,
suffix);
519 inFileNamesTable[
i], dstFileName,
550 char* circularBuf = (
char*)
malloc(circularBufSize);
554 if (!circularBuf)
EXM_THROW(25,
"Allocation error : not enough memory for circular buffer");
555 if (!dictFilename)
EXM_THROW(25,
"Dictionary error : no filename provided");
558 if (!dictFile)
EXM_THROW(25,
"Dictionary error : could not open dictionary file");
567 readSize = fread(circularBuf + dictEnd, 1, circularBufSize - dictEnd, dictFile);
568 dictEnd = (dictEnd + readSize) % circularBufSize;
570 }
while (readSize>0);
578 dictStart = (circularBufSize + dictEnd - dictLen) % circularBufSize;
580 if (dictStart == 0) {
582 dictBuf = circularBuf;
586 dictBuf = (
char *)
malloc(dictLen ? dictLen : 1);
587 if (!dictBuf)
EXM_THROW(25,
"Allocation error : not enough memory");
589 memcpy(dictBuf, circularBuf + dictStart, circularBufSize - dictStart);
590 memcpy(dictBuf + circularBufSize - dictStart, circularBuf, dictLen - (circularBufSize - dictStart));
601 size_t dictionarySize;
602 void* dictionaryBuffer;
606 if (!dictionaryBuffer)
EXM_THROW(25,
"Dictionary error : could not create dictionary");
608 free(dictionaryBuffer);
614 const size_t blockSize = prefs->
blockSize;
651 const char* srcFileName,
const char* dstFileName,
654 unsigned long long filesize = 0;
655 unsigned long long compressedfilesize = 0;
660 const size_t blockSize = io_prefs->
blockSize;
667 if (srcFile ==
NULL)
return 1;
669 if (dstFile ==
NULL) { fclose(srcFile);
return 1; }
670 memset(&prefs, 0,
sizeof(prefs));
684 DISPLAYLEVEL(3,
"Warning : cannot determine input content size \n");
688 readSize = fread(srcBuffer, (
size_t)1, blockSize, srcFile);
689 if (ferror(srcFile))
EXM_THROW(30,
"Error reading %s ", srcFileName);
690 filesize += readSize;
693 if (readSize < blockSize) {
698 compressedfilesize = cSize;
700 (
unsigned)(filesize>>20), (
double)compressedfilesize/(filesize+!filesize)*100);
703 if (fwrite(dstBuffer, 1, cSize, dstFile) != cSize) {
704 EXM_THROW(32,
"Write error : failed writing single-block compressed frame");
714 if (fwrite(dstBuffer, 1, headerSize, dstFile) != headerSize)
715 EXM_THROW(34,
"Write error : cannot write header");
716 compressedfilesize += headerSize;
723 compressedfilesize += outSize;
725 (
unsigned)(filesize>>20), (
double)compressedfilesize/filesize*100);
728 if (fwrite(dstBuffer, 1, outSize, dstFile) != outSize)
729 EXM_THROW(36,
"Write error : cannot write compressed block");
732 readSize = fread(srcBuffer, (
size_t)1, (
size_t)blockSize, srcFile);
733 filesize += readSize;
735 if (ferror(srcFile))
EXM_THROW(37,
"Error reading %s ", srcFileName);
741 if (fwrite(dstBuffer, 1, endSize, dstFile) != endSize)
742 EXM_THROW(39,
"Write error : cannot write end of frame");
743 compressedfilesize += endSize;
748 if (strcmp(dstFileName,
stdoutmark)) fclose (dstFile);
754 && strcmp (dstFileName,
nulmark)
760 if (remove(srcFileName))
761 EXM_THROW(40,
"Remove error : %s: %s", srcFileName, strerror(errno));
766 DISPLAYLEVEL(2,
"Compressed %llu bytes into %llu bytes ==> %.2f%%\n",
767 filesize, compressedfilesize,
768 (
double)compressedfilesize / (filesize + !filesize ) * 100);
777 clock_t const cpuStart = clock();
786 {
clock_t const cpuEnd = clock();
787 double const cpuLoad_s = (double)(cpuEnd - cpuStart) / CLOCKS_PER_SEC;
789 double const timeLength_s = (double)timeLength_ns / 1000000000;
790 DISPLAYLEVEL(4,
"Completed in %.2f sec (cpu load : %.0f%%)\n",
791 timeLength_s, (cpuLoad_s / timeLength_s) * 100);
799 const char** inFileNamesTable,
int ifntSize,
805 int missed_files = 0;
808 const size_t suffixSize = strlen(
suffix);
811 if (dstFileName ==
NULL)
return ifntSize;
815 for (
i=0;
i<ifntSize;
i++) {
816 size_t const ifnSize = strlen(inFileNamesTable[
i]);
823 if (ofnSize <= ifnSize+suffixSize+1) {
825 ofnSize = ifnSize + 20;
826 dstFileName = (
char*)
malloc(ofnSize);
827 if (dstFileName==
NULL) {
831 strcpy(dstFileName, inFileNamesTable[
i]);
832 strcat(dstFileName,
suffix);
835 inFileNamesTable[
i], dstFileName,
854 const unsigned char*
const srcPtr = (
const unsigned char*)
s;
855 unsigned value32 = srcPtr[0];
856 value32 += (
unsigned)srcPtr[1] << 8;
857 value32 += (
unsigned)srcPtr[2] << 16;
858 value32 += (
unsigned)srcPtr[3] << 24;
865 const void*
buffer,
size_t bufferSize,
866 int sparseFileSupport,
867 unsigned storedSkips)
869 const size_t sizeT =
sizeof(
size_t);
870 const size_t maskT = sizeT -1 ;
871 const size_t*
const bufferT = (
const size_t*)
buffer;
872 const size_t* ptrT = bufferT;
873 size_t bufferSizeT = bufferSize / sizeT;
874 const size_t*
const bufferTEnd = bufferT + bufferSizeT;
875 const size_t segmentSizeT = (32
KB) / sizeT;
876 int const sparseMode = (sparseFileSupport - (
file==stdout)) > 0;
879 size_t const sizeCheck = fwrite(
buffer, 1, bufferSize,
file);
880 if (sizeCheck != bufferSize)
EXM_THROW(70,
"Write error : cannot write decoded block");
885 if (storedSkips > 1
GB) {
887 if (seekResult != 0)
EXM_THROW(71,
"1 GB skip error (sparse file support)");
891 while (ptrT < bufferTEnd) {
892 size_t seg0SizeT = segmentSizeT;
896 if (seg0SizeT > bufferSizeT) seg0SizeT = bufferSizeT;
897 bufferSizeT -= seg0SizeT;
898 for (nb0T=0; (nb0T < seg0SizeT) && (ptrT[nb0T] == 0); nb0T++) ;
899 storedSkips += (
unsigned)(nb0T * sizeT);
901 if (nb0T != seg0SizeT) {
904 if (seekResult)
EXM_THROW(72,
"Sparse skip error(%d): %s ; try --no-sparse", (
int)errno, strerror(errno));
909 {
size_t const sizeCheck = fwrite(ptrT, sizeT, seg0SizeT,
file);
910 if (sizeCheck != seg0SizeT)
EXM_THROW(73,
"Write error : cannot write decoded block");
915 if (bufferSize & maskT) {
916 const char*
const restStart = (
const char*)bufferTEnd;
917 const char* restPtr = restStart;
918 size_t const restSize = bufferSize & maskT;
919 const char*
const restEnd = restStart + restSize;
920 for (; (restPtr < restEnd) && (*restPtr == 0); restPtr++) ;
921 storedSkips += (
unsigned) (restPtr - restStart);
922 if (restPtr != restEnd) {
924 if (seekResult)
EXM_THROW(74,
"Sparse skip error ; try --no-sparse");
926 {
size_t const sizeCheck = fwrite(restPtr, 1, (
size_t)(restEnd - restPtr),
file);
927 if (sizeCheck != (
size_t)(restEnd - restPtr))
EXM_THROW(75,
"Write error : cannot write decoded end of block");
937 const char lastZeroByte[1] = { 0 };
939 EXM_THROW(69,
"Final skip error (sparse file)\n");
940 if (fwrite(lastZeroByte, 1, 1,
file) != 1)
941 EXM_THROW(69,
"Write error : cannot write last zero\n");
949 unsigned long long streamSize = 0;
950 unsigned storedSkips = 0;
955 if (!in_buff || !out_buff)
EXM_THROW(51,
"Allocation error : not enough memory");
959 unsigned int blockSize;
962 {
size_t const sizeCheck = fread(in_buff, 1, 4, finput);
963 if (sizeCheck == 0)
break;
964 if (sizeCheck != 4)
EXM_THROW(52,
"Read error : cannot access block size "); }
973 {
size_t const sizeCheck = fread(in_buff, 1, blockSize, finput);
974 if (sizeCheck!=blockSize)
EXM_THROW(52,
"Read error : cannot access compressed block !"); }
978 if (decodeSize < 0)
EXM_THROW(53,
"Decoding Failed ! Corrupted input detected !");
979 streamSize += (
unsigned long long)decodeSize;
983 if (ferror(finput))
EXM_THROW(54,
"Read error : ferror");
1051 static unsigned long long
1053 FILE*
const srcFile,
FILE*
const dstFile,
1056 unsigned long long filesize = 0;
1058 unsigned storedSkips = 0;
1069 for (;nextToLoad;) {
1076 readSize = fread(ress.
srcBuffer, 1, nextToLoad, srcFile);
1077 if (!readSize)
break;
1081 size_t remaining = readSize -
pos;
1091 filesize += decodedBytes;
1092 DISPLAYUPDATE(2,
"\rDecompressed : %u MB ", (
unsigned)(filesize>>20));
1095 if (!nextToLoad)
break;
1099 if (ferror(srcFile))
EXM_THROW(67,
"Read error");
1102 if (nextToLoad!=0)
EXM_THROW(68,
"Unfinished stream");
1113 #define PTSIZE (64 KB)
1114 #define PTSIZET (PTSIZE / sizeof(size_t))
1115 static unsigned long long
1118 int sparseFileSupport)
1121 size_t readBytes = 1;
1123 unsigned storedSkips = 0;
1126 EXM_THROW(50,
"Pass-through write error");
1133 if (ferror(finput))
EXM_THROW(51,
"Read Error");
1143 const unsigned stepMax = 1U << 30;
1149 if (
s > stepMax)
s = stepMax;
1151 if (errorNb != 0)
break;
1157 #define ENDOFSTREAM ((unsigned long long)-1)
1158 static unsigned long long
1164 unsigned magicNumber;
1165 static unsigned nbFrames = 0;
1176 if (nbReadBytes==0) { nbFrames = 0;
return ENDOFSTREAM; }
1178 EXM_THROW(40,
"Unrecognized header : Magic Number unreadable");
1192 DISPLAYLEVEL(4,
"Skipping detected skippable area \n");
1193 {
size_t const nbReadBytes = fread(MNstore, 1, 4, finput);
1194 if (nbReadBytes != 4)
1195 EXM_THROW(42,
"Stream error : skippable size unreadable");
1200 EXM_THROW(43,
"Stream error : cannot skip skippable area");
1205 if (nbFrames == 1) {
1211 EXM_THROW(44,
"Unrecognized header : file cannot be decoded");
1213 {
long int const position = ftell(finput);
1214 DISPLAYLEVEL(2,
"Stream followed by undecodable data ");
1215 if (position != -1L)
1226 const char* input_filename,
const char* output_filename,
1230 unsigned long long filesize = 0;
1234 if (finput==
NULL)
return 1;
1239 unsigned long long const decodedSize =
1242 filesize += decodedSize;
1248 if (remove(input_filename))
1249 EXM_THROW(45,
"Remove error : %s: %s", input_filename, strerror(errno));
1254 DISPLAYLEVEL(2,
"%-20.20s : decoded %llu bytes \n", input_filename, filesize);
1255 (void)output_filename;
1263 const char* input_filename,
const char* output_filename,
1267 int stat_result = 0;
1269 if (foutput==
NULL)
return 1;
1281 if ( stat_result != 0
1283 && strcmp (output_filename,
nulmark)) {
1300 double const seconds = (double)(
end -
start) / CLOCKS_PER_SEC;
1304 return missingFiles;
1309 const char** inFileNamesTable,
int ifntSize,
1314 int skippedFiles = 0;
1315 int missingFiles = 0;
1318 size_t const suffixSize = strlen(
suffix);
1321 if (outFileName==
NULL)
EXM_THROW(70,
"Memory allocation error");
1324 for (
i=0;
i<ifntSize;
i++) {
1325 size_t const ifnSize = strlen(inFileNamesTable[
i]);
1326 const char*
const suffixPtr = inFileNamesTable[
i] + ifnSize - suffixSize;
1331 if (ofnSize <= ifnSize-suffixSize+1) {
1333 ofnSize = ifnSize + 20;
1334 outFileName = (
char*)
malloc(ofnSize);
1335 if (outFileName==
NULL)
EXM_THROW(71,
"Memory allocation error");
1337 if (ifnSize <= suffixSize || strcmp(suffixPtr,
suffix) != 0) {
1338 DISPLAYLEVEL(1,
"File extension doesn't match expected LZ4_EXTENSION (%4s); will not process file: %s\n",
suffix, inFileNamesTable[
i]);
1342 memcpy(outFileName, inFileNamesTable[
i], ifnSize - suffixSize);
1343 outFileName[ifnSize-suffixSize] =
'\0';
1349 return missingFiles + skippedFiles;
1369 #define LZ4IO_INIT_FRAMEINFO { LZ4F_INIT_FRAMEINFO, lz4Frame }
1381 #define LZ4IO_INIT_CFILEINFO { NULL, 0ULL, 0, LZ4IO_INIT_FRAMEINFO, 1, 1, 1 }
1393 static unsigned long long
1399 unsigned long long totalBlocksSize = 0;
1402 if (feof(finput))
return totalBlocksSize;
1406 {
const unsigned long nextCBlockSize =
LZ4IO_readLE32(&blockInfo) & 0x7FFFFFFFU;
1408 if (nextCBlockSize == 0) {
1410 if (contentChecksumFlag) {
1419 totalBlocksSize += nextBlock;
1421 assert(nextBlock < LONG_MAX);
1424 return totalBlocksSize;
1437 unsigned long long totalBlocksSize = 0;
1441 if (feof(finput))
return totalBlocksSize;
1444 {
const unsigned int nextCBlockSize =
LZ4IO_readLE32(&blockInfo);
1459 return totalBlocksSize;
1469 buffer[1] = (char)(sizeID +
'0');
1478 const char units[] = {
"\0KMGTPEZY"};
1488 const char*
b = strrchr(input_filename,
'/');
1489 if (!
b)
b = strrchr(input_filename,
'\\');
1490 if (!
b)
return input_filename;
1509 while (!feof(finput)) {
1511 unsigned magicNumber;
1514 if (nbReadBytes == 0) {
break; }
1517 EXM_THROW(40,
"Unrecognized header : Magic Number unreadable");
1523 switch (magicNumber) {
1528 if (!readBytes || ferror(finput))
EXM_THROW(71,
"Error reading %s", input_filename);
1535 if (!readBytes || ferror(finput))
EXM_THROW(72,
"Error reading %s", input_filename);
1542 if (frameInfoError)
break;
1550 if (totalBlocksSize) {
1551 char bTypeBuffer[5];
1561 totalBlocksSize + hSize,
1569 DISPLAYLEVEL(3,
" %20llu %20s %9s \n", totalBlocksSize + hSize,
"-",
"-");
1581 if (totalBlocksSize) {
1582 DISPLAYLEVEL(3,
" %6llu %14s %5s %8s %20llu %20s %9s\n",
1586 totalBlocksSize + 4,
1596 {
size_t const nbReadBytes = fread(
buffer, 1, 4, finput);
1597 if (nbReadBytes != 4)
1598 EXM_THROW(42,
"Stream error : skippable size unreadable");
1603 EXM_THROW(43,
"Stream error : cannot skip skippable area");
1607 "-",
"-",
size + 8,
"-",
"-");
1613 {
long int const position = ftell(finput);
1614 DISPLAYLEVEL(3,
"Stream followed by undecodable data ");
1615 if (position != -1L)
1635 DISPLAYOUT(
"%10s %14s %5s %11s %13s %9s %s\n",
1636 "Frames",
"Type",
"Block",
"Compressed",
"Uncompressed",
"Ratio",
"Filename");
1638 for (;
idx < ifnIdx;
idx++) {
1643 DISPLAYLEVEL(1,
"lz4: %s is not a regular file \n", inFileNames[
idx]);
1648 "Frame",
"Type",
"Block",
"Checksum",
"Compressed",
"Uncompressed",
"Ratio")
1652 DISPLAYLEVEL(1,
"lz4: %s: File format not recognized \n", inFileNames[
idx]);
1658 {
char buffers[3][10];
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 start
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 long
unsigned char suffix[65536]
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * malloc(size_t size)
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
UTIL_STATIC int UTIL_isRegFile(const char *infilename)
UTIL_STATIC U64 UTIL_getOpenFileSize(FILE *file)
UTIL_STATIC UTIL_time_t UTIL_getTime(void)
UTIL_STATIC int UTIL_setFileStat(const char *filename, stat_t *statbuf)
UTIL_STATIC int UTIL_getFileStat(const char *infilename, stat_t *statbuf)
UTIL_STATIC U64 UTIL_clockSpanNano(UTIL_time_t clockStart)
int LZ4_compressBound(int isize)
int LZ4_compress_fast(const char *source, char *dest, int inputSize, int maxOutputSize, int acceleration)
LZ4_FORCE_O2 int LZ4_decompress_safe(const char *source, char *dest, int compressedSize, int maxDecompressedSize)
#define LZ4_COMPRESSBOUND(isize)
LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx *dctx)
size_t LZ4F_compressUpdate(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr)
LZ4F_CDict * LZ4F_createCDict(const void *dictBuffer, size_t dictSize)
size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
size_t LZ4F_compressFrame_usingCDict(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr)
size_t LZ4F_decompress_usingDict(LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const void *dict, size_t dictSize, const LZ4F_decompressOptions_t *decompressOptionsPtr)
LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx *cctxPtr)
unsigned LZ4F_isError(LZ4F_errorCode_t code)
LZ4F_errorCode_t LZ4F_getFrameInfo(LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx **LZ4F_decompressionContextPtr, unsigned versionNumber)
LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx **LZ4F_compressionContextPtr, unsigned version)
void LZ4F_freeCDict(LZ4F_CDict *cdict)
const char * LZ4F_getErrorName(LZ4F_errorCode_t code)
size_t LZ4F_compressEnd(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr)
size_t LZ4F_headerSize(const void *src, size_t srcSize)
size_t LZ4F_compressBegin_usingCDict(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr)
#define LZ4F_HEADER_SIZE_MAX
#define LZ4F_BLOCK_HEADER_SIZE
#define LZ4F_HEADER_SIZE_MIN
#define LZ4F_CONTENT_CHECKSUM_SIZE
#define LZ4F_BLOCK_CHECKSUM_SIZE
int LZ4_compress_HC(const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel)
char int int compressionLevel
int LZ4IO_setPassThrough(LZ4IO_prefs_t *const prefs, int yes)
int LZ4IO_displayCompressedFilesInfo(const char **inFileNames, size_t ifnIdx)
int LZ4IO_setDictionaryFilename(LZ4IO_prefs_t *const prefs, const char *dictionaryFilename)
static FILE * LZ4IO_openSrcFile(const char *srcFileName)
int LZ4IO_compressFilename(const char *srcFileName, const char *dstFileName, int compressionLevel, const LZ4IO_prefs_t *prefs)
static int LZ4IO_decompressSrcFile(dRess_t ress, const char *input_filename, const char *output_filename, const LZ4IO_prefs_t *const prefs)
static int LZ4IO_isSkippableMagicNumber(unsigned int magic)
int LZ4IO_compressMultipleFilenames_Legacy(const char **inFileNamesTable, int ifntSize, const char *suffix, int compressionLevel, const LZ4IO_prefs_t *prefs)
#define EXM_THROW(error,...)
int LZ4IO_setBlockMode(LZ4IO_prefs_t *const prefs, LZ4IO_blockMode_t blockMode)
static cRess_t LZ4IO_createCResources(const LZ4IO_prefs_t *const prefs)
static dRess_t LZ4IO_createDResources(const LZ4IO_prefs_t *const prefs)
static LZ4IO_infoResult LZ4IO_getCompressedFileInfo(LZ4IO_cFileInfo_t *cfinfo, const char *input_filename)
static unsigned long long LZ4IO_skipLegacyBlocksData(FILE *finput)
static LZ4F_CDict * LZ4IO_createCDict(const LZ4IO_prefs_t *const prefs)
void LZ4IO_favorDecSpeed(LZ4IO_prefs_t *const prefs, int favor)
static unsigned long long selectDecoder(dRess_t ress, FILE *finput, FILE *foutput, const LZ4IO_prefs_t *const prefs)
#define DISPLAYUPDATE(l,...)
int LZ4IO_setStreamChecksumMode(LZ4IO_prefs_t *const prefs, int enable)
size_t LZ4IO_setBlockSize(LZ4IO_prefs_t *const prefs, size_t blockSize)
static void LZ4IO_loadDDict(dRess_t *ress, const LZ4IO_prefs_t *const prefs)
int LZ4IO_setOverwrite(LZ4IO_prefs_t *const prefs, int yes)
#define LZ4IO_BLOCKSIZEID_DEFAULT
static const char * LZ4IO_frameTypeNames[]
#define LZ4IO_STATIC_ASSERT(c)
static const size_t LZ4IO_dBufferSize
static void LZ4IO_writeLE32(void *p, unsigned value32)
static unsigned LZ4IO_readLE32(const void *s)
static int LZ4IO_decompressDstFile(dRess_t ress, const char *input_filename, const char *output_filename, const LZ4IO_prefs_t *const prefs)
int LZ4IO_decompressFilename(const char *input_filename, const char *output_filename, const LZ4IO_prefs_t *prefs)
#define LZ4IO_INIT_CFILEINFO
int LZ4IO_compressMultipleFilenames(const char **inFileNamesTable, int ifntSize, const char *suffix, int compressionLevel, const LZ4IO_prefs_t *prefs)
size_t LZ4IO_setBlockSizeID(LZ4IO_prefs_t *const prefs, unsigned bsid)
static void LZ4IO_freeCResources(cRess_t ress)
static unsigned long long LZ4IO_skipBlocksData(FILE *finput, const LZ4F_blockChecksum_t blockChecksumFlag, const LZ4F_contentChecksum_t contentChecksumFlag)
static int LZ4IO_compressFilename_extRess(cRess_t ress, const char *srcFileName, const char *dstFileName, int compressionLevel, const LZ4IO_prefs_t *const io_prefs)
static FILE * LZ4IO_openDstFile(const char *dstFileName, const LZ4IO_prefs_t *const prefs)
#define DISPLAYLEVEL(l,...)
static unsigned long long LZ4IO_passThrough(FILE *finput, FILE *foutput, unsigned char MNstore[MAGICNUMBER_SIZE], int sparseFileSupport)
int LZ4IO_setSparseFile(LZ4IO_prefs_t *const prefs, int enable)
#define LEGACY_MAGICNUMBER
#define LZ4IO_SKIPPABLEMASK
int LZ4IO_compressFilename_Legacy(const char *input_filename, const char *output_filename, int compressionlevel, const LZ4IO_prefs_t *prefs)
static unsigned LZ4IO_fwriteSparse(FILE *file, const void *buffer, size_t bufferSize, int sparseFileSupport, unsigned storedSkips)
int LZ4IO_setBlockChecksumMode(LZ4IO_prefs_t *const prefs, int enable)
static int LZ4IO_LZ4_compress(const char *src, char *dst, int srcSize, int dstSize, int cLevel)
static void * LZ4IO_createDict(size_t *dictSize, const char *const dictFilename)
#define LZ4_MAX_DICT_SIZE
static unsigned long long LZ4IO_decodeLegacyStream(FILE *finput, FILE *foutput, const LZ4IO_prefs_t *prefs)
static unsigned g_magicRead
void LZ4IO_setRemoveSrcFile(LZ4IO_prefs_t *const prefs, unsigned flag)
static int g_displayLevel
#define LZ4IO_MAGICNUMBER
LZ4IO_prefs_t * LZ4IO_defaultPreferences(void)
int LZ4IO_setTestMode(LZ4IO_prefs_t *const prefs, int yes)
static void LZ4IO_fwriteSparseEnd(FILE *file, unsigned storedSkips)
#define LZ4IO_INIT_FRAMEINFO
static const char * LZ4IO_toHuman(long double size, char *buf)
void LZ4IO_freePreferences(LZ4IO_prefs_t *prefs)
static const clock_t refreshRate
static const char * LZ4IO_baseName(const char *input_filename)
static int fseek_u32(FILE *fp, unsigned offset, int where)
int LZ4IO_decompressMultipleFilenames(const char **inFileNamesTable, int ifntSize, const char *suffix, const LZ4IO_prefs_t *prefs)
static void LZ4IO_freeDResources(dRess_t ress)
int LZ4IO_setNotificationLevel(int level)
int LZ4IO_setContentSize(LZ4IO_prefs_t *const prefs, int enable)
const char * LZ4IO_blockTypeID(LZ4F_blockSizeID_t sizeID, LZ4F_blockMode_t blockMode, char buffer[4])
static unsigned long long LZ4IO_decompressLZ4F(dRess_t ress, FILE *const srcFile, FILE *const dstFile, const LZ4IO_prefs_t *const prefs)
#define LZIO_LEGACY_BLOCK_HEADER_SIZE
assert(limit<=UINT32_MAX/2)
LZ4F_contentChecksum_t contentChecksumFlag
unsigned long long contentSize
LZ4F_blockChecksum_t blockChecksumFlag
LZ4F_blockMode_t blockMode
LZ4F_blockSizeID_t blockSizeID
LZ4F_frameInfo_t frameInfo
unsigned short eqFrameTypes
unsigned long long frameCount
LZ4IO_frameInfo_t frameSummary
unsigned long long fileSize
unsigned short allContentSize
unsigned short eqBlockTypes
LZ4F_frameInfo_t lz4FrameInfo
LZ4IO_frameType_t frameType
const char * dictionaryFilename
LZ4F_compressionContext_t ctx
LZ4F_decompressionContext_t dCtx
Miscellaneous utility functions.