Rizin
unix-like reverse engineering framework and cli tools
lz4io.h File Reference
#include <stddef.h>

Go to the source code of this file.

Macros

#define stdinmark   "stdin"
 
#define stdoutmark   "stdout"
 
#define NULL_OUTPUT   "null"
 
#define nulmark   "/dev/null"
 
#define LZIO_LEGACY_BLOCK_HEADER_SIZE   4
 

Typedefs

typedef struct LZ4IO_prefs_s LZ4IO_prefs_t
 

Enumerations

enum  LZ4IO_blockMode_t { LZ4IO_blockLinked =0 , LZ4IO_blockIndependent }
 

Functions

LZ4IO_prefs_tLZ4IO_defaultPreferences (void)
 
void LZ4IO_freePreferences (LZ4IO_prefs_t *prefs)
 
int LZ4IO_compressFilename (const char *input_filename, const char *output_filename, int compressionlevel, const LZ4IO_prefs_t *prefs)
 
int LZ4IO_decompressFilename (const char *input_filename, const char *output_filename, const LZ4IO_prefs_t *prefs)
 
int LZ4IO_compressMultipleFilenames (const char **inFileNamesTable, int ifntSize, const char *suffix, int compressionlevel, const LZ4IO_prefs_t *prefs)
 
int LZ4IO_decompressMultipleFilenames (const char **inFileNamesTable, int ifntSize, const char *suffix, const LZ4IO_prefs_t *prefs)
 
int LZ4IO_setDictionaryFilename (LZ4IO_prefs_t *const prefs, const char *dictionaryFilename)
 
int LZ4IO_setPassThrough (LZ4IO_prefs_t *const prefs, int yes)
 
int LZ4IO_setOverwrite (LZ4IO_prefs_t *const prefs, int yes)
 
int LZ4IO_setTestMode (LZ4IO_prefs_t *const prefs, int yes)
 
size_t LZ4IO_setBlockSizeID (LZ4IO_prefs_t *const prefs, unsigned blockSizeID)
 
size_t LZ4IO_setBlockSize (LZ4IO_prefs_t *const prefs, size_t blockSize)
 
int LZ4IO_setBlockMode (LZ4IO_prefs_t *const prefs, LZ4IO_blockMode_t blockMode)
 
int LZ4IO_setBlockChecksumMode (LZ4IO_prefs_t *const prefs, int xxhash)
 
int LZ4IO_setStreamChecksumMode (LZ4IO_prefs_t *const prefs, int xxhash)
 
int LZ4IO_setNotificationLevel (int level)
 
int LZ4IO_setSparseFile (LZ4IO_prefs_t *const prefs, int enable)
 
int LZ4IO_setContentSize (LZ4IO_prefs_t *const prefs, int enable)
 
void LZ4IO_setRemoveSrcFile (LZ4IO_prefs_t *const prefs, unsigned flag)
 
void LZ4IO_favorDecSpeed (LZ4IO_prefs_t *const prefs, int favor)
 
int LZ4IO_displayCompressedFilesInfo (const char **inFileNames, size_t ifnIdx)
 

Macro Definition Documentation

◆ LZIO_LEGACY_BLOCK_HEADER_SIZE

#define LZIO_LEGACY_BLOCK_HEADER_SIZE   4

Definition at line 61 of file lz4io.h.

◆ NULL_OUTPUT

#define NULL_OUTPUT   "null"

Definition at line 44 of file lz4io.h.

◆ nulmark

#define nulmark   "/dev/null"

Definition at line 48 of file lz4io.h.

◆ stdinmark

#define stdinmark   "stdin"

Definition at line 42 of file lz4io.h.

◆ stdoutmark

#define stdoutmark   "stdout"

Definition at line 43 of file lz4io.h.

Typedef Documentation

◆ LZ4IO_prefs_t

typedef struct LZ4IO_prefs_s LZ4IO_prefs_t

Definition at line 1 of file lz4io.h.

Enumeration Type Documentation

◆ LZ4IO_blockMode_t

Enumerator
LZ4IO_blockLinked 
LZ4IO_blockIndependent 

Definition at line 103 of file lz4io.h.

LZ4IO_blockMode_t
Definition: lz4io.h:103
@ LZ4IO_blockLinked
Definition: lz4io.h:103
@ LZ4IO_blockIndependent
Definition: lz4io.h:103

Function Documentation

◆ LZ4IO_compressFilename()

int LZ4IO_compressFilename ( const char *  input_filename,
const char *  output_filename,
int  compressionlevel,
const LZ4IO_prefs_t prefs 
)

Definition at line 774 of file lz4io.c.

775 {
776  UTIL_time_t const timeStart = UTIL_getTime();
777  clock_t const cpuStart = clock();
778  cRess_t const ress = LZ4IO_createCResources(prefs);
779 
780  int const result = LZ4IO_compressFilename_extRess(ress, srcFileName, dstFileName, compressionLevel, prefs);
781 
782  /* Free resources */
783  LZ4IO_freeCResources(ress);
784 
785  /* Final Status */
786  { clock_t const cpuEnd = clock();
787  double const cpuLoad_s = (double)(cpuEnd - cpuStart) / CLOCKS_PER_SEC;
788  U64 const timeLength_ns = UTIL_clockSpanNano(timeStart);
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);
792  }
793 
794  return result;
795 }
UTIL_STATIC UTIL_time_t UTIL_getTime(void)
Definition: util.h:277
clock_t UTIL_time_t
Definition: util.h:276
UTIL_STATIC U64 UTIL_clockSpanNano(UTIL_time_t clockStart)
Definition: util.h:291
unsigned long long U64
Definition: lz4.c:290
char int int compressionLevel
Definition: lz4hc.h:258
static cRess_t LZ4IO_createCResources(const LZ4IO_prefs_t *const prefs)
Definition: lz4io.c:612
static void LZ4IO_freeCResources(cRess_t ress)
Definition: lz4io.c:632
static int LZ4IO_compressFilename_extRess(cRess_t ress, const char *srcFileName, const char *dstFileName, int compressionLevel, const LZ4IO_prefs_t *const io_prefs)
Definition: lz4io.c:650
#define DISPLAYLEVEL(l,...)
Definition: lz4io.c:94
int clock_t
Definition: sftypes.h:43
Definition: lz4io.c:534

References compressionLevel, DISPLAYLEVEL, LZ4IO_compressFilename_extRess(), LZ4IO_createCResources(), LZ4IO_freeCResources(), UTIL_clockSpanNano(), and UTIL_getTime().

◆ LZ4IO_compressMultipleFilenames()

int LZ4IO_compressMultipleFilenames ( const char **  inFileNamesTable,
int  ifntSize,
const char *  suffix,
int  compressionlevel,
const LZ4IO_prefs_t prefs 
)

Definition at line 798 of file lz4io.c.

803 {
804  int i;
805  int missed_files = 0;
806  char* dstFileName = (char*)malloc(FNSPACE);
807  size_t ofnSize = FNSPACE;
808  const size_t suffixSize = strlen(suffix);
809  cRess_t ress;
810 
811  if (dstFileName == NULL) return ifntSize; /* not enough memory */
812  ress = LZ4IO_createCResources(prefs);
813 
814  /* loop on each file */
815  for (i=0; i<ifntSize; i++) {
816  size_t const ifnSize = strlen(inFileNamesTable[i]);
817  if (!strcmp(suffix, stdoutmark)) {
818  missed_files += LZ4IO_compressFilename_extRess(ress,
819  inFileNamesTable[i], stdoutmark,
820  compressionLevel, prefs);
821  continue;
822  }
823  if (ofnSize <= ifnSize+suffixSize+1) {
824  free(dstFileName);
825  ofnSize = ifnSize + 20;
826  dstFileName = (char*)malloc(ofnSize);
827  if (dstFileName==NULL) {
828  LZ4IO_freeCResources(ress);
829  return ifntSize;
830  } }
831  strcpy(dstFileName, inFileNamesTable[i]);
832  strcat(dstFileName, suffix);
833 
834  missed_files += LZ4IO_compressFilename_extRess(ress,
835  inFileNamesTable[i], dstFileName,
836  compressionLevel, prefs);
837  }
838 
839  /* Close & Free */
840  LZ4IO_freeCResources(ress);
841  free(dstFileName);
842 
843  return missed_files;
844 }
lzma_index ** i
Definition: index.h:629
#define NULL
Definition: cris-opc.c:27
unsigned char suffix[65536]
Definition: gun.c:164
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
void * malloc(size_t size)
Definition: malloc.c:123
#define FNSPACE
Definition: lz4io.c:481
#define stdoutmark
Definition: lz4io.h:43

References compressionLevel, FNSPACE, free(), i, LZ4IO_compressFilename_extRess(), LZ4IO_createCResources(), LZ4IO_freeCResources(), malloc(), NULL, stdoutmark, and suffix.

Referenced by main().

◆ LZ4IO_decompressFilename()

int LZ4IO_decompressFilename ( const char *  input_filename,
const char *  output_filename,
const LZ4IO_prefs_t prefs 
)

Definition at line 1292 of file lz4io.c.

1293 {
1294  dRess_t const ress = LZ4IO_createDResources(prefs);
1295  clock_t const start = clock();
1296 
1297  int const missingFiles = LZ4IO_decompressDstFile(ress, input_filename, output_filename, prefs);
1298 
1299  clock_t const end = clock();
1300  double const seconds = (double)(end - start) / CLOCKS_PER_SEC;
1301  DISPLAYLEVEL(4, "Done in %.2f sec \n", seconds);
1302 
1303  LZ4IO_freeDResources(ress);
1304  return missingFiles;
1305 }
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
Definition: sflib.h:133
static dRess_t LZ4IO_createDResources(const LZ4IO_prefs_t *const prefs)
Definition: lz4io.c:1020
static int LZ4IO_decompressDstFile(dRess_t ress, const char *input_filename, const char *output_filename, const LZ4IO_prefs_t *const prefs)
Definition: lz4io.c:1262
static void LZ4IO_freeDResources(dRess_t ress)
Definition: lz4io.c:1041
Definition: lz4io.c:996

References DISPLAYLEVEL, test_evm::end, LZ4IO_createDResources(), LZ4IO_decompressDstFile(), LZ4IO_freeDResources(), and start.

◆ LZ4IO_decompressMultipleFilenames()

int LZ4IO_decompressMultipleFilenames ( const char **  inFileNamesTable,
int  ifntSize,
const char *  suffix,
const LZ4IO_prefs_t prefs 
)

Definition at line 1308 of file lz4io.c.

1312 {
1313  int i;
1314  int skippedFiles = 0;
1315  int missingFiles = 0;
1316  char* outFileName = (char*)malloc(FNSPACE);
1317  size_t ofnSize = FNSPACE;
1318  size_t const suffixSize = strlen(suffix);
1319  dRess_t ress = LZ4IO_createDResources(prefs);
1320 
1321  if (outFileName==NULL) EXM_THROW(70, "Memory allocation error");
1322  ress.dstFile = LZ4IO_openDstFile(stdoutmark, prefs);
1323 
1324  for (i=0; i<ifntSize; i++) {
1325  size_t const ifnSize = strlen(inFileNamesTable[i]);
1326  const char* const suffixPtr = inFileNamesTable[i] + ifnSize - suffixSize;
1327  if (!strcmp(suffix, stdoutmark)) {
1328  missingFiles += LZ4IO_decompressSrcFile(ress, inFileNamesTable[i], stdoutmark, prefs);
1329  continue;
1330  }
1331  if (ofnSize <= ifnSize-suffixSize+1) {
1332  free(outFileName);
1333  ofnSize = ifnSize + 20;
1334  outFileName = (char*)malloc(ofnSize);
1335  if (outFileName==NULL) EXM_THROW(71, "Memory allocation error");
1336  }
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]);
1339  skippedFiles++;
1340  continue;
1341  }
1342  memcpy(outFileName, inFileNamesTable[i], ifnSize - suffixSize);
1343  outFileName[ifnSize-suffixSize] = '\0';
1344  missingFiles += LZ4IO_decompressDstFile(ress, inFileNamesTable[i], outFileName, prefs);
1345  }
1346 
1347  LZ4IO_freeDResources(ress);
1348  free(outFileName);
1349  return missingFiles + skippedFiles;
1350 }
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static int LZ4IO_decompressSrcFile(dRess_t ress, const char *input_filename, const char *output_filename, const LZ4IO_prefs_t *const prefs)
Definition: lz4io.c:1225
#define EXM_THROW(error,...)
Definition: lz4io.c:137
static FILE * LZ4IO_openDstFile(const char *dstFileName, const LZ4IO_prefs_t *const prefs)
Definition: lz4io.c:332
FILE * dstFile
Definition: lz4io.c:1001

References DISPLAYLEVEL, dRess_t::dstFile, EXM_THROW, FNSPACE, free(), i, LZ4IO_createDResources(), LZ4IO_decompressDstFile(), LZ4IO_decompressSrcFile(), LZ4IO_freeDResources(), LZ4IO_openDstFile(), malloc(), memcpy(), NULL, stdoutmark, and suffix.

Referenced by main().

◆ LZ4IO_defaultPreferences()

LZ4IO_prefs_t* LZ4IO_defaultPreferences ( void  )

Definition at line 160 of file lz4io.c.

161 {
162  LZ4IO_prefs_t* const ret = (LZ4IO_prefs_t*)malloc(sizeof(*ret));
163  if (!ret) EXM_THROW(21, "Allocation error : not enough memory");
164  ret->passThrough = 0;
165  ret->overwrite = 1;
166  ret->testMode = 0;
168  ret->blockSize = 0;
169  ret->blockChecksum = 0;
170  ret->streamChecksum = 1;
171  ret->blockIndependence = 1;
172  ret->sparseFileSupport = 1;
173  ret->contentSizeFlag = 0;
174  ret->useDictionary = 0;
175  ret->favorDecSpeed = 0;
176  ret->dictionaryFilename = NULL;
177  ret->removeSrcFile = 0;
178  return ret;
179 }
#define LZ4IO_BLOCKSIZEID_DEFAULT
Definition: lz4io.c:85
int contentSizeFlag
Definition: lz4io.c:123
int sparseFileSupport
Definition: lz4io.c:122
int testMode
Definition: lz4io.c:116
int useDictionary
Definition: lz4io.c:124
int removeSrcFile
Definition: lz4io.c:127
int passThrough
Definition: lz4io.c:114
unsigned favorDecSpeed
Definition: lz4io.c:125
size_t blockSize
Definition: lz4io.c:118
const char * dictionaryFilename
Definition: lz4io.c:126
int blockIndependence
Definition: lz4io.c:121
int blockChecksum
Definition: lz4io.c:119
int blockSizeId
Definition: lz4io.c:117
int streamChecksum
Definition: lz4io.c:120
int overwrite
Definition: lz4io.c:115

References LZ4IO_prefs_s::blockChecksum, LZ4IO_prefs_s::blockIndependence, LZ4IO_prefs_s::blockSize, LZ4IO_prefs_s::blockSizeId, LZ4IO_prefs_s::contentSizeFlag, LZ4IO_prefs_s::dictionaryFilename, EXM_THROW, LZ4IO_prefs_s::favorDecSpeed, LZ4IO_BLOCKSIZEID_DEFAULT, malloc(), NULL, LZ4IO_prefs_s::overwrite, LZ4IO_prefs_s::passThrough, LZ4IO_prefs_s::removeSrcFile, LZ4IO_prefs_s::sparseFileSupport, LZ4IO_prefs_s::streamChecksum, LZ4IO_prefs_s::testMode, and LZ4IO_prefs_s::useDictionary.

Referenced by main().

◆ LZ4IO_displayCompressedFilesInfo()

int LZ4IO_displayCompressedFilesInfo ( const char **  inFileNames,
size_t  ifnIdx 
)

Definition at line 1630 of file lz4io.c.

1631 {
1632  int result = 0;
1633  size_t idx = 0;
1634  if (g_displayLevel < 3) {
1635  DISPLAYOUT("%10s %14s %5s %11s %13s %9s %s\n",
1636  "Frames", "Type", "Block", "Compressed", "Uncompressed", "Ratio", "Filename");
1637  }
1638  for (; idx < ifnIdx; idx++) {
1639  /* Get file info */
1641  cfinfo.fileName = LZ4IO_baseName(inFileNames[idx]);
1642  if (!UTIL_isRegFile(inFileNames[idx])) {
1643  DISPLAYLEVEL(1, "lz4: %s is not a regular file \n", inFileNames[idx]);
1644  return 0;
1645  }
1646  DISPLAYLEVEL(3, "%s(%llu/%llu)\n", cfinfo.fileName, (unsigned long long)idx + 1, (unsigned long long)ifnIdx);
1647  DISPLAYLEVEL(3, " %6s %14s %5s %8s %20s %20s %9s\n",
1648  "Frame", "Type", "Block", "Checksum", "Compressed", "Uncompressed", "Ratio")
1649  { LZ4IO_infoResult const op_result = LZ4IO_getCompressedFileInfo(&cfinfo, inFileNames[idx]);
1650  if (op_result != LZ4IO_LZ4F_OK) {
1651  assert(op_result == LZ4IO_format_not_known);
1652  DISPLAYLEVEL(1, "lz4: %s: File format not recognized \n", inFileNames[idx]);
1653  return 0;
1654  } }
1655  DISPLAYLEVEL(3, "\n");
1656  if (g_displayLevel < 3) {
1657  /* Display Summary */
1658  { char buffers[3][10];
1659  DISPLAYOUT("%10llu %14s %5s %11s %13s ",
1660  cfinfo.frameCount,
1661  cfinfo.eqFrameTypes ? LZ4IO_frameTypeNames[cfinfo.frameSummary.frameType] : "-" ,
1663  cfinfo.frameSummary.lz4FrameInfo.blockMode, buffers[0]) : "-",
1664  LZ4IO_toHuman((long double)cfinfo.fileSize, buffers[1]),
1665  cfinfo.allContentSize ? LZ4IO_toHuman((long double)cfinfo.frameSummary.lz4FrameInfo.contentSize, buffers[2]) : "-");
1666  if (cfinfo.allContentSize) {
1667  double const ratio = (double)cfinfo.fileSize / cfinfo.frameSummary.lz4FrameInfo.contentSize * 100;
1668  DISPLAYOUT("%9.2f%% %s \n", ratio, cfinfo.fileName);
1669  } else {
1670  DISPLAYOUT("%9s %s\n",
1671  "-",
1672  cfinfo.fileName);
1673  } } } /* if (g_displayLevel < 3) */
1674  } /* for (; idx < ifnIdx; idx++) */
1675 
1676  return result;
1677 }
UTIL_STATIC int UTIL_isRegFile(const char *infilename)
Definition: util.h:368
static LZ4IO_infoResult LZ4IO_getCompressedFileInfo(LZ4IO_cFileInfo_t *cfinfo, const char *input_filename)
Definition: lz4io.c:1500
static const char * LZ4IO_frameTypeNames[]
Definition: lz4io.c:1385
#define DISPLAYOUT(...)
Definition: lz4io.c:93
#define LZ4IO_INIT_CFILEINFO
Definition: lz4io.c:1381
static int g_displayLevel
Definition: lz4io.c:95
static const char * LZ4IO_toHuman(long double size, char *buf)
Definition: lz4io.c:1476
static const char * LZ4IO_baseName(const char *input_filename)
Definition: lz4io.c:1486
LZ4IO_infoResult
Definition: lz4io.c:1383
@ LZ4IO_format_not_known
Definition: lz4io.c:1383
@ LZ4IO_LZ4F_OK
Definition: lz4io.c:1383
const char * LZ4IO_blockTypeID(LZ4F_blockSizeID_t sizeID, LZ4F_blockMode_t blockMode, char buffer[4])
Definition: lz4io.c:1465
assert(limit<=UINT32_MAX/2)
int idx
Definition: setup.py:197
unsigned long long contentSize
Definition: lz4frame.h:180
LZ4F_blockMode_t blockMode
Definition: lz4frame.h:177
LZ4F_blockSizeID_t blockSizeID
Definition: lz4frame.h:176
unsigned short eqFrameTypes
Definition: lz4io.c:1376
const char * fileName
Definition: lz4io.c:1372
unsigned long long frameCount
Definition: lz4io.c:1374
LZ4IO_frameInfo_t frameSummary
Definition: lz4io.c:1375
unsigned long long fileSize
Definition: lz4io.c:1373
unsigned short allContentSize
Definition: lz4io.c:1378
unsigned short eqBlockTypes
Definition: lz4io.c:1377
LZ4F_frameInfo_t lz4FrameInfo
Definition: lz4io.c:1365
LZ4IO_frameType_t frameType
Definition: lz4io.c:1366

References LZ4IO_cFileInfo_t::allContentSize, assert(), LZ4F_frameInfo_t::blockMode, LZ4F_frameInfo_t::blockSizeID, LZ4F_frameInfo_t::contentSize, DISPLAYLEVEL, DISPLAYOUT, LZ4IO_cFileInfo_t::eqBlockTypes, LZ4IO_cFileInfo_t::eqFrameTypes, LZ4IO_cFileInfo_t::fileName, LZ4IO_cFileInfo_t::fileSize, LZ4IO_cFileInfo_t::frameCount, LZ4IO_cFileInfo_t::frameSummary, LZ4IO_frameInfo_t::frameType, g_displayLevel, setup::idx, LZ4IO_frameInfo_t::lz4FrameInfo, LZ4IO_baseName(), LZ4IO_blockTypeID(), LZ4IO_format_not_known, LZ4IO_frameTypeNames, LZ4IO_getCompressedFileInfo(), LZ4IO_INIT_CFILEINFO, LZ4IO_LZ4F_OK, LZ4IO_toHuman(), and UTIL_isRegFile().

Referenced by main().

◆ LZ4IO_favorDecSpeed()

void LZ4IO_favorDecSpeed ( LZ4IO_prefs_t *const  prefs,
int  favor 
)

Definition at line 288 of file lz4io.c.

289 {
290  prefs->favorDecSpeed = (favor!=0);
291 }

References LZ4IO_prefs_s::favorDecSpeed.

Referenced by main().

◆ LZ4IO_freePreferences()

void LZ4IO_freePreferences ( LZ4IO_prefs_t prefs)

Definition at line 181 of file lz4io.c.

182 {
183  free(prefs);
184 }

References free().

Referenced by main().

◆ LZ4IO_setBlockChecksumMode()

int LZ4IO_setBlockChecksumMode ( LZ4IO_prefs_t *const  prefs,
int  xxhash 
)

Definition at line 253 of file lz4io.c.

254 {
255  prefs->blockChecksum = (enable != 0);
256  return prefs->blockChecksum;
257 }

References LZ4IO_prefs_s::blockChecksum.

Referenced by main().

◆ LZ4IO_setBlockMode()

int LZ4IO_setBlockMode ( LZ4IO_prefs_t *const  prefs,
LZ4IO_blockMode_t  blockMode 
)

Definition at line 246 of file lz4io.c.

247 {
248  prefs->blockIndependence = (blockMode == LZ4IO_blockIndependent);
249  return prefs->blockIndependence;
250 }

References LZ4IO_prefs_s::blockIndependence, and LZ4IO_blockIndependent.

Referenced by main().

◆ LZ4IO_setBlockSize()

size_t LZ4IO_setBlockSize ( LZ4IO_prefs_t *const  prefs,
size_t  blockSize 
)

Definition at line 228 of file lz4io.c.

229 {
230  static const size_t minBlockSize = 32;
231  static const size_t maxBlockSize = 4 MB;
232  unsigned bsid = 0;
233  if (blockSize < minBlockSize) blockSize = minBlockSize;
234  if (blockSize > maxBlockSize) blockSize = maxBlockSize;
235  prefs->blockSize = blockSize;
236  blockSize--;
237  /* find which of { 64k, 256k, 1MB, 4MB } is closest to blockSize */
238  while (blockSize >>= 2)
239  bsid++;
240  if (bsid < 7) bsid = 7;
241  prefs->blockSizeId = (int)(bsid-3);
242  return prefs->blockSize;
243 }
#define MB
Definition: lz4io.c:67
static int
Definition: sfsocketcall.h:114

References LZ4IO_prefs_s::blockSize, LZ4IO_prefs_s::blockSizeId, int, and MB.

Referenced by main().

◆ LZ4IO_setBlockSizeID()

size_t LZ4IO_setBlockSizeID ( LZ4IO_prefs_t *const  prefs,
unsigned  blockSizeID 
)

Definition at line 217 of file lz4io.c.

218 {
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;
223  prefs->blockSizeId = (int)bsid;
224  prefs->blockSize = blockSizeTable[(unsigned)prefs->blockSizeId-minBlockSizeID];
225  return prefs->blockSize;
226 }
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
Definition: sflib.h:97
#define KB
Definition: lz4io.c:66

References LZ4IO_prefs_s::blockSize, LZ4IO_prefs_s::blockSizeId, int, KB, MB, and unsigned.

Referenced by main().

◆ LZ4IO_setContentSize()

int LZ4IO_setContentSize ( LZ4IO_prefs_t *const  prefs,
int  enable 
)

Definition at line 281 of file lz4io.c.

282 {
283  prefs->contentSizeFlag = (enable!=0);
284  return prefs->contentSizeFlag;
285 }

References LZ4IO_prefs_s::contentSizeFlag.

Referenced by main().

◆ LZ4IO_setDictionaryFilename()

int LZ4IO_setDictionaryFilename ( LZ4IO_prefs_t *const  prefs,
const char *  dictionaryFilename 
)

Definition at line 187 of file lz4io.c.

188 {
189  prefs->dictionaryFilename = dictionaryFilename;
190  prefs->useDictionary = dictionaryFilename != NULL;
191  return prefs->useDictionary;
192 }

References LZ4IO_prefs_s::dictionaryFilename, NULL, and LZ4IO_prefs_s::useDictionary.

Referenced by main().

◆ LZ4IO_setNotificationLevel()

int LZ4IO_setNotificationLevel ( int  level)

Definition at line 267 of file lz4io.c.

268 {
270  return g_displayLevel;
271 }
static int level
Definition: vmenus.c:2424

References g_displayLevel, and level.

Referenced by main().

◆ LZ4IO_setOverwrite()

int LZ4IO_setOverwrite ( LZ4IO_prefs_t *const  prefs,
int  yes 
)

Definition at line 203 of file lz4io.c.

204 {
205  prefs->overwrite = (yes!=0);
206  return prefs->overwrite;
207 }

References LZ4IO_prefs_s::overwrite.

Referenced by main().

◆ LZ4IO_setPassThrough()

int LZ4IO_setPassThrough ( LZ4IO_prefs_t *const  prefs,
int  yes 
)

Definition at line 195 of file lz4io.c.

196 {
197  prefs->passThrough = (yes!=0);
198  return prefs->passThrough;
199 }

References LZ4IO_prefs_s::passThrough.

Referenced by main().

◆ LZ4IO_setRemoveSrcFile()

void LZ4IO_setRemoveSrcFile ( LZ4IO_prefs_t *const  prefs,
unsigned  flag 
)

Definition at line 293 of file lz4io.c.

294 {
295  prefs->removeSrcFile = (flag>0);
296 }

References LZ4IO_prefs_s::removeSrcFile.

Referenced by main().

◆ LZ4IO_setSparseFile()

int LZ4IO_setSparseFile ( LZ4IO_prefs_t *const  prefs,
int  enable 
)

Definition at line 274 of file lz4io.c.

275 {
276  prefs->sparseFileSupport = 2*(enable!=0); /* 2==force enable */
277  return prefs->sparseFileSupport;
278 }

References LZ4IO_prefs_s::sparseFileSupport.

Referenced by main().

◆ LZ4IO_setStreamChecksumMode()

int LZ4IO_setStreamChecksumMode ( LZ4IO_prefs_t *const  prefs,
int  xxhash 
)

Definition at line 260 of file lz4io.c.

261 {
262  prefs->streamChecksum = (enable != 0);
263  return prefs->streamChecksum;
264 }

References LZ4IO_prefs_s::streamChecksum.

Referenced by main().

◆ LZ4IO_setTestMode()

int LZ4IO_setTestMode ( LZ4IO_prefs_t *const  prefs,
int  yes 
)

Definition at line 210 of file lz4io.c.

211 {
212  prefs->testMode = (yes!=0);
213  return prefs->testMode;
214 }

References LZ4IO_prefs_s::testMode.

Referenced by main().