Name Date Size #Lines LOC

..--

.gitignoreH A D25-Apr-2025187 2320

Android.bpH A D25-Apr-2025989 5450

COPYINGH A D25-Apr-202514.6 KiB8451

MakefileH A D25-Apr-20257.6 KiB237163

README.mdH A D25-Apr-20256.7 KiB11594

bench.cH A D25-Apr-202532.9 KiB866673

bench.hH A D25-Apr-20252.8 KiB5514

lorem.cH A D25-Apr-202512.7 KiB367288

lorem.hH A D25-Apr-20251.6 KiB475

lz4-exe.rc.inH A D25-Apr-2025850 2726

lz4.1H A D25-Apr-202510.4 KiB265263

lz4.1.mdH A D25-Apr-20259.5 KiB274199

lz4cli.cH A D25-Apr-202537.4 KiB888683

lz4conf.hH A D25-Apr-20252.2 KiB7222

lz4io.cH A D25-Apr-2025104.2 KiB2,8982,248

lz4io.hH A D25-Apr-20255 KiB13637

platform.hH A D25-Apr-20257 KiB15898

threadpool.cH A D25-Apr-202512.8 KiB431275

threadpool.hH A D25-Apr-20252 KiB6914

timefn.cH A D25-Apr-20254.7 KiB176110

timefn.hH A D25-Apr-20252.2 KiB7319

util.cH A D25-Apr-20254 KiB16696

util.hH A D25-Apr-202517.7 KiB568419

README.md

1Command Line Interface for LZ4 library
2============================================
3
4### Build
5The `lz4` Command Line Interface (CLI) is generated
6using the `make` command, no additional parameter required.
7
8The CLI generates and decodes [LZ4-compressed frames](../doc/lz4_Frame_format.md).
9
10For more control over the build process,
11the `Makefile` script supports all [standard conventions](https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html),
12including standard targets (`all`, `install`, `clean`, etc.)
13and standard variables (`CC`, `CFLAGS`, `CPPFLAGS`, etc.).
14
15The makefile offer several targets for various use cases:
16- `lz4` : default CLI, with a command line syntax similar to gzip
17- `lz4c` : supports legacy lz4 commands (incompatible with gzip)
18- `lz4c32` : Same as `lz4c`, but generates a 32-bits executable
19- `unlz4`, `lz4cat` : symlinks to `lz4`, default to decompression and `cat` compressed files
20- `man` : generates the man page, from `lz4.1.md` markdown source
21
22#### Makefile Build variables
23- `HAVE_MULTITHREAD` : build with multithreading support. Detection is generally automatic, but can be forced to `0` or `1` if needed. This is for example useful when cross-compiling for Windows from Linux.
24- `HAVE_PTHREAD` : determines presence of `<pthread>` support. Detection is automatic, but can be forced to `0` or `1` if needed. This is in turn used by `make` to automatically trigger multithreading support.
25
26#### C Preprocessor Build variables
27These variables are read by the preprocessor at compilation time. They influence executable behavior, such as default starting values, and are exposed from `programs/lz4conf.h`. These variables can manipulated by any build system.
28Assignment methods vary depending on environments.
29On a typical `posix` + `gcc` + `make` setup, they can be defined with `CPPFLAGS=-DVARIABLE=value` assignment.
30- `LZ4_CLEVEL_DEFAULT`: default compression level when none provided. Default is `1`.
31- `LZ4IO_MULTITHREAD`: enable multithreading support. Default is disabled.
32- `LZ4_NBWORKERS_DEFAULT`: default nb of worker threads used in multithreading mode (can be overridden with command `-T#`).
33   Default is `0`, which means "auto-determine" based on local cpu.
34- `LZ4_NBWORKERS_MAX`: absolute maximum nb of workers that can be requested at runtime.
35   Currently set to 200 by default.
36   This is mostly meant to protect the system against unreasonable and likely bogus requests, such as a million threads.
37- `LZ4_BLOCKSIZEID_DEFAULT`: default `lz4` block size code. Valid values are [4-7], corresponding to 64 KB, 256 KB, 1 MB and 4 MB. At the time of this writing, default is 7, corresponding to 4 MB block size.
38
39#### Environment Variables
40It's possible to pass some parameters to `lz4` via environment variables.
41This can be useful in situations where `lz4` is known to be invoked (from within a script for example) but there is no way to pass `lz4` parameters to influence the compression session.
42The environment variable has higher priority than binary default, but lower priority than corresponding runtime command.
43When set as global environment variables, it can enforce personalized defaults different from the binary set ones.
44
45`LZ4_CLEVEL` can be used to specify a default compression level that `lz4` employs for compression when no other compression level is specified on command line. Executable default is generally `1`.
46
47`LZ4_NBWORKERS` can be used to specify a default number of threads that `lz4` will employ for compression. Executable default is generally `0`, which means auto-determined based on local cpu. This functionality is only relevant when `lz4` is compiled with multithreading support. The maximum number of workers is capped at `LZ4_NBWORKERS_MAX` (`200` by default).
48
49### Aggregation of parameters
50The `lz4` CLI supports aggregation for short commands. For example, `-d`, `-q`, and `-f` can be joined into `-dqf`.
51Aggregation doesn't work for `--long-commands`, which **must** be separated.
52
53
54### Benchmark in Command Line Interface
55`lz4` CLI includes an in-memory compression benchmark module, triggered by command `-b#`, with `#` representing the compression level.
56The benchmark is conducted on a provided list of filenames.
57The files are then read entirely into memory, to eliminate I/O overhead.
58When multiple files are provided, they are bundled into the same benchmark session (though each file is a separate compression / decompression). Using `-S` command separates them (one session per file).
59When no file is provided, uses an internal Lorem Ipsum generator instead.
60
61The benchmark measures ratio, compressed size, compression and decompression speed.
62One can select multiple compression levels starting from `-b` and ending with `-e` (ascending).
63The `-i` parameter selects a number of seconds used for each session.
64
65
66### Usage of Command Line Interface
67The full list of commands can be obtained with `-h` or `-H` parameter:
68```
69Usage :
70      lz4 [arg] [input] [output]
71
72input   : a filename
73          with no FILE, or when FILE is - or stdin, read standard input
74Arguments :
75 -1     : Fast compression (default)
76 -9     : High compression
77 -d     : decompression (default for .lz4 extension)
78 -z     : force compression
79 -D FILE: use FILE as dictionary
80 -f     : overwrite output without prompting
81 -k     : preserve source files(s)  (default)
82--rm    : remove source file(s) after successful de/compression
83 -h/-H  : display help/long help and exit
84
85Advanced arguments :
86 -V     : display Version number and exit
87 -v     : verbose mode
88 -q     : suppress warnings; specify twice to suppress errors too
89 -c     : force write to standard output, even if it is the console
90 -t     : test compressed file integrity
91 -m     : multiple input files (implies automatic output filenames)
92 -r     : operate recursively on directories (sets also -m)
93 -l     : compress using Legacy format (Linux kernel compression)
94 -B#    : cut file into blocks of size # bytes [32+]
95                     or predefined block size [4-7] (default: 7)
96 -BD    : Block dependency (improve compression ratio)
97 -BX    : enable block checksum (default:disabled)
98--no-frame-crc : disable stream checksum (default:enabled)
99--content-size : compressed frame includes original size (default:not present)
100--[no-]sparse  : sparse mode (default:enabled on file, disabled on stdout)
101--favor-decSpeed: compressed files decompress faster, but are less compressed
102--fast[=#]: switch to ultra fast compression level (default: 1)
103
104Benchmark arguments :
105 -b#    : benchmark file(s), using # compression level (default : 1)
106 -e#    : test all compression levels from -bX to # (default : 1)
107 -i#    : minimum evaluation time in seconds (default : 3s)```
108```
109
110#### License
111
112All files in this directory are licensed under GPL-v2.
113See [COPYING](COPYING) for details.
114The text of the license is also included at the top of each source file.
115