diff options
author | Yann Collet <cyan@fb.com> | 2016-09-03 02:32:06 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2016-09-03 02:32:06 (GMT) |
commit | 64f556e610b68e6781e05d2d6470ebf8b8dff45c (patch) | |
tree | f541f4fbc7c2d999b63527324613f77f3d3d42bb /programs/lz4cli.c | |
parent | 5871585b6a28c6582d1626b8d07bb1a53a4cbd9d (diff) | |
download | lz4-64f556e610b68e6781e05d2d6470ebf8b8dff45c.zip lz4-64f556e610b68e6781e05d2d6470ebf8b8dff45c.tar.gz lz4-64f556e610b68e6781e05d2d6470ebf8b8dff45c.tar.bz2 |
lz4cli version number from lz4.h
Diffstat (limited to 'programs/lz4cli.c')
-rw-r--r-- | programs/lz4cli.c | 69 |
1 files changed, 28 insertions, 41 deletions
diff --git a/programs/lz4cli.c b/programs/lz4cli.c index a583481..3e09073 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -62,6 +62,8 @@ #include "bench.h" /* BMK_benchFile, BMK_SetNbIterations, BMK_SetBlocksize, BMK_SetPause */ #include "lz4io.h" /* LZ4IO_compressFilename, LZ4IO_decompressFilename, LZ4IO_compressMultipleFilenames */ #include "lz4hc.h" /* LZ4HC_DEFAULT_CLEVEL */ +#include "lz4.h" /* LZ4_VERSION_STRING */ + /**************************** * OS-specific Includes @@ -87,11 +89,8 @@ * Constants ******************************/ #define COMPRESSOR_NAME "LZ4 command line interface" -#ifndef LZ4_VERSION -# define LZ4_VERSION "r132" -#endif #define AUTHOR "Yann Collet" -#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s (%s) ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), LZ4_VERSION, AUTHOR, __DATE__ +#define WELCOME_MESSAGE "*** %s %i-bits %s, by %s ***\n", COMPRESSOR_NAME, (int)(sizeof(void*)*8), LZ4_VERSION_STRING, AUTHOR #define LZ4_EXTENSION ".lz4" #define LZ4CAT "lz4cat" #define UNLZ4 "unlz4" @@ -345,7 +344,6 @@ int main(int argc, const char** argv) if (!strcmp(argument, "--version")) { DISPLAY(WELCOME_MESSAGE); return 0; } if (!strcmp(argument, "--keep")) { continue; } /* keep source file (default anyway; just for xz/lzma compatibility) */ - /* Short commands (note : aggregated short commands are allowed) */ if (argument[0]=='-') { /* '-' means stdin/stdout */ @@ -414,8 +412,7 @@ int main(int argc, const char** argv) /* Modify Block Properties */ case 'B': - while (argument[1]!=0) - { + while (argument[1]!=0) { int exitBlockProperties=0; switch(argument[1]) { @@ -451,13 +448,10 @@ int main(int argc, const char** argv) /* Modify Nb Iterations (benchmark only) */ case 'i': - { unsigned iters = 0; - while ((argument[1] >='0') && (argument[1] <='9')) - { - iters *= 10; - iters += argument[1] - '0'; - argument++; - } + { unsigned iters; + argument++; + iters = readU32FromChar(&argument); + argument--; BMK_setNbIterations(iters); } break; @@ -482,8 +476,7 @@ int main(int argc, const char** argv) if (!input_filename) { input_filename=argument; continue; } /* Second non-option arg in output_filename to preserve original cli logic. */ - if (!output_filename) - { + if (!output_filename) { output_filename=argument; if (!strcmp (output_filename, nullOutput)) output_filename = nulmark; continue; @@ -501,31 +494,26 @@ int main(int argc, const char** argv) if(!input_filename) { input_filename=stdinmark; } /* Check if input is defined as console; trigger an error in this case */ - if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) ) - { + if (!strcmp(input_filename, stdinmark) && IS_CONSOLE(stdin) ) { DISPLAYLEVEL(1, "refusing to read from a console\n"); exit(1); } /* Check if benchmark is selected */ - if (bench) - { + if (bench) { int bmkResult = BMK_benchFiles(inFileNames, ifnIdx, cLevel, cLevelLast); free((void*)inFileNames); return bmkResult; } /* No output filename ==> try to select one automatically (when possible) */ - while (!output_filename) - { + while (!output_filename) { if (!IS_CONSOLE(stdout)) { output_filename=stdoutmark; break; } /* Default to stdout whenever possible (i.e. not a console) */ - if ((!decode) && !(forceCompress)) /* auto-determine compression or decompression, based on file extension */ - { + if ((!decode) && !(forceCompress)) { /* auto-determine compression or decompression, based on file extension */ size_t const l = strlen(input_filename); if (!strcmp(input_filename+(l-4), LZ4_EXTENSION)) decode=1; } - if (!decode) /* compression to file */ - { + if (!decode) { /* compression to file */ size_t const l = strlen(input_filename); dynNameSpace = (char*)calloc(1,l+5); if (dynNameSpace==NULL) exit(1); @@ -536,8 +524,7 @@ int main(int argc, const char** argv) break; } /* decompression to file (automatic name will work only if input filename has correct format extension) */ - { - size_t outl; + { size_t outl; size_t inl = strlen(input_filename); dynNameSpace = (char*)calloc(1,inl+1); strcpy(dynNameSpace, input_filename); @@ -563,21 +550,21 @@ int main(int argc, const char** argv) /* IO Stream/File */ LZ4IO_setNotificationLevel(displayLevel); if (decode) { - if (multiple_inputs) - operationResult = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION); - else - DEFAULT_DECOMPRESSOR(input_filename, output_filename); - } else { - /* compression is default action */ - if (legacy_format) { - DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated) ! \n"); - LZ4IO_compressFilename_Legacy(input_filename, output_filename, cLevel); - } else { if (multiple_inputs) - operationResult = LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel); + operationResult = LZ4IO_decompressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION); else - DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel); - } + DEFAULT_DECOMPRESSOR(input_filename, output_filename); + } else { + /* compression is default action */ + if (legacy_format) { + DISPLAYLEVEL(3, "! Generating compressed LZ4 using Legacy format (deprecated) ! \n"); + LZ4IO_compressFilename_Legacy(input_filename, output_filename, cLevel); + } else { + if (multiple_inputs) + operationResult = LZ4IO_compressMultipleFilenames(inFileNames, ifnIdx, LZ4_EXTENSION, cLevel); + else + DEFAULT_COMPRESSOR(input_filename, output_filename, cLevel); + } } _cleanup: |