extlz4 0.2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,220 @@
1
+ #!ruby
2
+ #vim: set fileencoding:utf-8
3
+
4
+ # AUTHOR: dearblue <dearblue@users.noreply.github.com>
5
+ # Only this program is usable as public domain software.
6
+
7
+ require "extlz4"
8
+ require "optparse"
9
+ require "find"
10
+
11
+ PROGNAME = File.basename(__FILE__)
12
+ opt = OptionParser.new(<<-EOS, 8, " ")
13
+ Usage: #{PROGNAME} [option]... [file]...
14
+
15
+ This program is likely lz4-cli. Reinventing the wheel.
16
+ EOS
17
+
18
+ class << opt
19
+ #
20
+ # Define hidden switch.
21
+ #
22
+ def hide_on(opt, &block)
23
+ top.short[opt.to_s[1]] ||= OptionParser::Switch::NoArgument.new(&block)
24
+ end
25
+ end
26
+
27
+ mode = nil
28
+ verbose = 1
29
+ opt.separator("")
30
+ level = 1
31
+ opt.on("-1", "fastest (worst) compression (default)") { mode = :encode; level = 1 }
32
+ opt.separator(" -2 .. -8 set compression level")
33
+ opt.hide_on("-2") { mode = :encode; level = 2 }
34
+ opt.hide_on("-3") { mode = :encode; level = 3 }
35
+ opt.hide_on("-4") { mode = :encode; level = 4 }
36
+ opt.hide_on("-5") { mode = :encode; level = 5 }
37
+ opt.hide_on("-6") { mode = :encode; level = 6 }
38
+ opt.hide_on("-7") { mode = :encode; level = 7 }
39
+ opt.hide_on("-8") { mode = :encode; level = 8 }
40
+ opt.on("-9", "best (slowest) compression") { mode = :encode; level = 9 }
41
+ outstdout = false
42
+ opt.on("-c", "write to stdout, keep original files") { outstdout = true }
43
+ opt.on("-d", "uncompress files") { mode = :decode }
44
+ forceoverwrite = false
45
+ opt.on("-f", "force overwriting of output file") { forceoverwrite = true }
46
+ keepfile = false
47
+ opt.on("-k", "don't delete input files during operation") { keepfile = true }
48
+ opt.on("-q", "output no warnings") { verbose = 0 }
49
+ recursive = false
50
+ opt.on("-r", "recursively compress files in directories") { recursive = true }
51
+ opt.on("-t", "test compressed file") { mode = :test }
52
+ opt.on("-v", "increment verbosery level") { verbose += 1 }
53
+ outdir = nil
54
+ opt.on("-Cdir", "set output directory") { |dir| outdir = dir }
55
+ blocksize = 0
56
+ blockdep = false
57
+ blockchecksum = false
58
+ opt.separator(" -B# set block size [4-7] (default: 7)") # merged to "-BD"
59
+ opt.on("-BD", "set mode to block dependency (improve compression ratio)", %w[4 5 6 7 D]) do |o|
60
+ case o
61
+ when ?4, ?5, ?6, ?7
62
+ blocksize = 1 << ((o.ord - ?0.ord) * 2 + 8)
63
+ when ?D
64
+ blockdep = true
65
+ else
66
+ 0/0
67
+ end
68
+ end
69
+ checksum = true
70
+ opt.on("-Sx", "disable content checksum (default: enabled)", %w(x)) { checksum = false }
71
+ opt.on("-V", "display program version") {
72
+ puts <<-EOS
73
+ #{PROGNAME}: extlz4-cli program version #{LZ4::VERSION} (powered by #{RUBY_ENGINE}-#{RUBY_VERSION})
74
+ EOS
75
+
76
+ exit 0
77
+ }
78
+
79
+ opt.separator <<EOS
80
+
81
+ temporary special operation:
82
+ EOS
83
+ opt.on("--fix-extlz4-0.1-bug",
84
+ "fix corrupted lz4 stream file for encoded by extlz4-0.1",
85
+ "this operation required xxhash (`gem install xxhash`)") { mode = :fix_extlz4_0_1_bug }
86
+
87
+ begin
88
+ opt.parse!
89
+ rescue OptionParser::InvalidOption, OptionParser::InvalidArgument
90
+ $stderr.puts <<-EOS
91
+ #{PROGNAME}: #{$!}
92
+ EOS
93
+ # $stderr.puts <<-EOS
94
+ ##{PROGNAME}: #{$!}
95
+ # enter ``#{PROGNAME} --help'' to print help.
96
+ # EOS
97
+ exit 1
98
+ end
99
+
100
+ def file_operation(outdir, infile, defaultoutfile, outstdout, forceoverwrite, keepfile)
101
+ case
102
+ when outstdout
103
+ outfile = $stdout.binmode
104
+ when infile == defaultoutfile # TODO: 大文字小文字を区別しないシステムも考慮すべし
105
+ $stderr.puts "#{PROGNAME}: out file name is same as in file - #{infile}"
106
+ else
107
+ outfile = defaultoutfile
108
+ outfile = File.join(outdir, File.basename(outfile)) if outdir
109
+ if !forceoverwrite && File.exist?(outfile)
110
+ $stderr.puts "#{PROGNAME}: file exists - #{outfile}. (with ``-f'' switch to overwrite)"
111
+ return false
112
+ end
113
+ end
114
+
115
+ yield(infile, outfile)
116
+
117
+ if !outstdout
118
+ t = File.mtime(infile)
119
+ File.utime(t, t, outfile)
120
+ File.unlink(infile) if !keepfile
121
+ end
122
+
123
+ true
124
+ end
125
+
126
+ def find_files(path, recursive = false)
127
+ unless File.directory?(path)
128
+ yield path
129
+ return nil
130
+ end
131
+
132
+ unless recursive
133
+ $stderr.puts "#{PROGNAME}: ignored directory - #{path}"
134
+ return nil
135
+ end
136
+
137
+ Find.find(path) do |path1|
138
+ yield path1 unless File.directory? path1
139
+ end
140
+
141
+ nil
142
+ end
143
+
144
+ begin
145
+ if ARGV.empty?
146
+ if $stdout.tty? && !forceoverwrite && mode != :decode && mode != :test
147
+ $stderr.puts <<-EOS
148
+ #{PROGNAME}: not written to terminal. use ``-f'' to force encode.
149
+ \tor enter ``#{PROGNAME} --help'' to print help.
150
+ EOS
151
+ exit 1
152
+ end
153
+
154
+ $stdin.binmode
155
+ $stdout.binmode
156
+
157
+ case mode
158
+ when :encode, nil
159
+ LZ4.encode_file($stdin, $stdout, level,
160
+ blocksize: blocksize,
161
+ blocklink: blockdep,
162
+ checksum: checksum)
163
+ when :decode
164
+ LZ4.decode_file($stdin, $stdout)
165
+ when :test
166
+ LZ4.test_file($stdin)
167
+ else
168
+ raise NotImplementedError
169
+ end
170
+
171
+ exit 0
172
+ else
173
+ ARGV.each do |file1|
174
+ file1 = file1.gsub(File::ALT_SEPARATOR, File::SEPARATOR) if File::ALT_SEPARATOR
175
+ find_files(file1, recursive) do |file|
176
+ begin
177
+ case
178
+ when mode == :decode || (mode.nil? && file =~ /\.lz4$/i)
179
+ file_operation(outdir, file, file.sub(/\.lz4$/i, ""), outstdout, forceoverwrite, keepfile) do |infile, outfile|
180
+ LZ4.decode_file(infile, outfile)
181
+ end
182
+ when mode == :encode || mode.nil?
183
+ file_operation(outdir, file, file + ".lz4", outstdout, forceoverwrite, keepfile) do |infile, outfile|
184
+ LZ4.encode_file(infile, outfile, level,
185
+ blocksize: blocksize,
186
+ blocklink: blockdep,
187
+ checksum: checksum)
188
+ end
189
+ when mode == :test
190
+ LZ4.test_file(file)
191
+ when mode == :fix_extlz4_0_1_bug
192
+ require "extlz4/oldstream"
193
+ require "extlz4/fix-0.1bug"
194
+
195
+ outname = file.sub(/(?<=#{File::SEPARATOR})(?=[^#{File::SEPARATOR}]+$)|^(?=[^#{File::SEPARATOR}]+$)/, "fixed-")
196
+ file_operation(outdir, file, outname, outstdout, forceoverwrite, true) do |infile, outfile|
197
+ if verbose > 0
198
+ $stderr.puts "#{PROGNAME}: correcting lz4 file - #{infile} to #{outfile}"
199
+ end
200
+ if verbose > 1
201
+ outinfo = ->(mesg, offset, total, *etc) do
202
+ $stderr.puts "#{mesg} (at #{offset} of #{total})"
203
+ end
204
+ end
205
+ LZ4.fix_extlz4_0_1_bug(infile, outfile, &outinfo)
206
+ end
207
+ else
208
+ $stderr.puts "#{PROGNAME}: mode error - #{mode}"
209
+ end
210
+ rescue LZ4::Error #, Object
211
+ $stderr.puts "#{PROGNAME}: #{file} - #$! (#{$!.class})"
212
+ end
213
+ end
214
+ end
215
+ end
216
+ rescue LZ4::Error
217
+ $stderr.puts "#{PROGNAME}: #$! (#{$!.class})"
218
+ rescue SystemCallError, SignalException
219
+ # do nothing
220
+ end
@@ -0,0 +1,15 @@
1
+ Installation
2
+ =============
3
+
4
+ ```
5
+ make
6
+ make install # this command may require root access
7
+ ```
8
+
9
+ LZ4's `Makefile` supports standard [Makefile conventions],
10
+ including [staged installs], [redirection], or [command redefinition].
11
+
12
+ [Makefile conventions]: https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
13
+ [staged installs]: https://www.gnu.org/prep/standards/html_node/DESTDIR.html
14
+ [redirection]: https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
15
+ [command redefinition]: https://www.gnu.org/prep/standards/html_node/Utilities-in-Makefiles.html
@@ -0,0 +1,11 @@
1
+ This repository uses 2 different licenses :
2
+ - all files in the `lib` directory use a BSD 2-Clause license
3
+ - all other files use a GPLv2 license, unless explicitly stated otherwise
4
+
5
+ Relevant license is reminded at the top of each source file,
6
+ and with presence of COPYING or LICENSE file in associated directories.
7
+
8
+ This model is selected to emphasize that
9
+ files in the `lib` directory are designed to be included into 3rd party applications,
10
+ while all other files, in `programs`, `tests` or `examples`,
11
+ receive more limited attention and support for such scenario.
@@ -0,0 +1,231 @@
1
+ v1.8.0
2
+ cli : fix : do not modify /dev/null permissions, reported by @Maokaman1
3
+ cli : added GNU separator -- specifying that all following arguments are files
4
+ API : added LZ4_compress_HC_destSize(), by Oleg (@remittor)
5
+ API : added LZ4F_resetDecompressionContext()
6
+ API : lz4frame : negative compression levels trigger fast acceleration, request by Lawrence Chan
7
+ API : lz4frame : can control block checksum and dictionary ID
8
+ API : fix : expose obsolete decoding functions, reported by Chen Yufei
9
+ API : experimental : lz4frame_static : new dictionary compression API
10
+ build : fix : static lib installation, by Ido Rosen
11
+ build : dragonFlyBSD, OpenBSD, NetBSD supported
12
+ build : LZ4_MEMORY_USAGE can be modified at compile time, through external define
13
+ doc : Updated LZ4 Frame format to v1.6.0, restoring Dictionary-ID field
14
+ doc : lz4 api manual, by Przemyslaw Skibinski
15
+
16
+ v1.7.5
17
+ lz4hc : new high compression mode : levels 10-12 compress more and slower, by Przemyslaw Skibinski
18
+ lz4cat : fix : works with relative path (#284) and stdin (#285) (reported by @beiDei8z)
19
+ cli : fix minor notification when using -r recursive mode
20
+ API : lz4frame : LZ4F_frameBound(0) gives upper bound of *flush() and *End() operations (#290, #280)
21
+ doc : markdown version of man page, by Takayuki Matsuoka (#279)
22
+ build : Makefile : fix make -jX lib+exe concurrency (#277)
23
+ build : cmake : improvements by Michał Górny (#296)
24
+
25
+ v1.7.4.2
26
+ fix : Makefile : release build compatible with PIE and customized compilation directives provided through environment variables (#274, reported by Antoine Martin)
27
+
28
+ v1.7.4
29
+ Improved : much better speed in -mx32 mode
30
+ cli : fix : Large file support in 32-bits mode on Mac OS-X
31
+ fix : compilation on gcc 4.4 (#272), reported by Antoine Martin
32
+
33
+ v1.7.3
34
+ Changed : moved to versioning; package, cli and library have same version number
35
+ Improved: Small decompression speed boost
36
+ Improved: Small compression speed improvement on 64-bits systems
37
+ Improved: Small compression ratio and speed improvement on small files
38
+ Improved: Significant speed boost on ARMv6 and ARMv7
39
+ Fix : better ratio on 64-bits big-endian targets
40
+ Improved cmake build script, by Evan Nemerson
41
+ New liblz4-dll project, by Przemyslaw Skibinki
42
+ Makefile: Generates object files (*.o) for faster (re)compilation on low power systems
43
+ cli : new : --rm and --help commands
44
+ cli : new : preserved file attributes, by Przemyslaw Skibinki
45
+ cli : fix : crash on some invalid inputs
46
+ cli : fix : -t correctly validates lz4-compressed files, by Nick Terrell
47
+ cli : fix : detects and reports fread() errors, thanks to Hiroshi Fujishima report #243
48
+ cli : bench : new : -r recursive mode
49
+ lz4cat : can cat multiple files in a single command line (#184)
50
+ Added : doc/lz4_manual.html, by Przemyslaw Skibinski
51
+ Added : dictionary compression and frame decompression examples, by Nick Terrell
52
+ Added : Debianization, by Evgeniy Polyakov
53
+
54
+ r131
55
+ New : Dos/DJGPP target, thanks to Louis Santillan (#114)
56
+ Added : Example using lz4frame library, by Zbigniew Jędrzejewski-Szmek (#118)
57
+ Changed: xxhash symbols are modified (namespace emulation) within liblz4
58
+
59
+ r130:
60
+ Fixed : incompatibility sparse mode vs console, reported by Yongwoon Cho (#105)
61
+ Fixed : LZ4IO exits too early when frame crc not present, reported by Yongwoon Cho (#106)
62
+ Fixed : incompatibility sparse mode vs append mode, reported by Takayuki Matsuoka (#110)
63
+ Performance fix : big compression speed boost for clang (+30%)
64
+ New : cross-version test, by Takayuki Matsuoka
65
+
66
+ r129:
67
+ Added : LZ4_compress_fast(), LZ4_compress_fast_continue()
68
+ Added : LZ4_compress_destSize()
69
+ Changed: New lz4 and lz4hc compression API. Previous function prototypes still supported.
70
+ Changed: Sparse file support enabled by default
71
+ New : LZ4 CLI improved performance compressing/decompressing multiple files (#86, kind contribution from Kyle J. Harper & Takayuki Matsuoka)
72
+ Fixed : GCC 4.9+ optimization bug - Reported by Markus Trippelsdorf, Greg Slazinski & Evan Nemerson
73
+ Changed: Enums converted to LZ4F_ namespace convention - by Takayuki Matsuoka
74
+ Added : AppVeyor CI environment, for Visual tests - Suggested by Takayuki Matsuoka
75
+ Modified:Obsolete functions generate warnings - Suggested by Evan Nemerson, contributed by Takayuki Matsuoka
76
+ Fixed : Bug #75 (unfinished stream), reported by Yongwoon Cho
77
+ Updated: Documentation converted to MarkDown format
78
+
79
+ r128:
80
+ New : lz4cli sparse file support (Requested by Neil Wilson, and contributed by Takayuki Matsuoka)
81
+ New : command -m, to compress multiple files in a single command (suggested by Kyle J. Harper)
82
+ Fixed : Restored lz4hc compression ratio (slightly lower since r124)
83
+ New : lz4 cli supports long commands (suggested by Takayuki Matsuoka)
84
+ New : lz4frame & lz4cli frame content size support
85
+ New : lz4frame supports skippable frames, as requested by Sergey Cherepanov
86
+ Changed: Default "make install" directory is /usr/local, as notified by Ron Johnson
87
+ New : lz4 cli supports "pass-through" mode, requested by Neil Wilson
88
+ New : datagen can generate sparse files
89
+ New : scan-build tests, thanks to kind help by Takayuki Matsuoka
90
+ New : g++ compatibility tests
91
+ New : arm cross-compilation test, thanks to kind help by Takayuki Matsuoka
92
+ Fixed : Fuzzer + frametest compatibility with NetBSD (issue #48, reported by Thomas Klausner)
93
+ Added : Visual project directory
94
+ Updated: Man page & Specification
95
+
96
+ r127:
97
+ N/A : added a file on SVN
98
+
99
+ r126:
100
+ New : lz4frame API is now integrated into liblz4
101
+ Fixed : GCC 4.9 bug on highest performance settings, reported by Greg Slazinski
102
+ Fixed : bug within LZ4 HC streaming mode, reported by James Boyle
103
+ Fixed : older compiler don't like nameless unions, reported by Cheyi Lin
104
+ Changed : lz4 is C90 compatible
105
+ Changed : added -pedantic option, fixed a few mminor warnings
106
+
107
+ r125:
108
+ Changed : endian and alignment code
109
+ Changed : directory structure : new "lib" directory
110
+ Updated : lz4io, now uses lz4frame
111
+ Improved: slightly improved decoding speed
112
+ Fixed : LZ4_compress_limitedOutput(); Special thanks to Christopher Speller !
113
+ Fixed : some alignment warnings under clang
114
+ Fixed : deprecated function LZ4_slideInputBufferHC()
115
+
116
+ r124:
117
+ New : LZ4 HC streaming mode
118
+ Fixed : LZ4F_compressBound() using null preferencesPtr
119
+ Updated : xxHash to r38
120
+ Updated library number, to 1.4.0
121
+
122
+ r123:
123
+ Added : experimental lz4frame API, thanks to Takayuki Matsuoka and Christopher Jackson for testings
124
+ Fix : s390x support, thanks to Nobuhiro Iwamatsu
125
+ Fix : test mode (-t) no longer requires confirmation, thanks to Thary Nguyen
126
+
127
+ r122:
128
+ Fix : AIX & AIX64 support (SamG)
129
+ Fix : mips 64-bits support (lew van)
130
+ Added : Examples directory, using code examples from Takayuki Matsuoka
131
+ Updated : Framing specification, to v1.4.1
132
+ Updated : xxHash, to r36
133
+
134
+ r121:
135
+ Added : Makefile : install for kFreeBSD and Hurd (Nobuhiro Iwamatsu)
136
+ Fix : Makefile : install for OS-X and BSD, thanks to Takayuki Matsuoka
137
+
138
+ r120:
139
+ Modified : Streaming API, using strong types
140
+ Added : LZ4_versionNumber(), thanks to Takayuki Matsuoka
141
+ Fix : OS-X : library install name, thanks to Clemens Lang
142
+ Updated : Makefile : synchronize library version number with lz4.h, thanks to Takayuki Matsuoka
143
+ Updated : Makefile : stricter compilation flags
144
+ Added : pkg-config, thanks to Zbigniew Jędrzejewski-Szmek (issue 135)
145
+ Makefile : lz4-test only test native binaries, as suggested by Michał Górny (issue 136)
146
+ Updated : xxHash to r35
147
+
148
+ r119:
149
+ Fix : Issue 134 : extended malicious address space overflow in 32-bits mode for some specific configurations
150
+
151
+ r118:
152
+ New : LZ4 Streaming API (Fast version), special thanks to Takayuki Matsuoka
153
+ New : datagen : parametrable synthetic data generator for tests
154
+ Improved : fuzzer, support more test cases, more parameters, ability to jump to specific test
155
+ fix : support ppc64le platform (issue 131)
156
+ fix : Issue 52 (malicious address space overflow in 32-bits mode when using large custom format)
157
+ fix : Makefile : minor issue 130 : header files permissions
158
+
159
+ r117:
160
+ Added : man pages for lz4c and lz4cat
161
+ Added : automated tests on Travis, thanks to Takayuki Matsuoka !
162
+ fix : block-dependency command line (issue 127)
163
+ fix : lz4fullbench (issue 128)
164
+
165
+ r116:
166
+ hotfix (issue 124 & 125)
167
+
168
+ r115:
169
+ Added : lz4cat utility, installed on POSX systems (issue 118)
170
+ OS-X compatible compilation of dynamic library (issue 115)
171
+
172
+ r114:
173
+ Makefile : library correctly compiled with -O3 switch (issue 114)
174
+ Makefile : library compilation compatible with clang
175
+ Makefile : library is versioned and linked (issue 119)
176
+ lz4.h : no more static inline prototypes (issue 116)
177
+ man : improved header/footer (issue 111)
178
+ Makefile : Use system default $(CC) & $(MAKE) variables (issue 112)
179
+ xxhash : updated to r34
180
+
181
+ r113:
182
+ Large decompression speed improvement for GCC 32-bits. Thanks to Valery Croizier !
183
+ LZ4HC : Compression Level is now a programmable parameter (CLI from 4 to 9)
184
+ Separated IO routines from command line (lz4io.c)
185
+ Version number into lz4.h (suggested by Francesc Alted)
186
+
187
+ r112:
188
+ quickfix
189
+
190
+ r111 :
191
+ Makefile : added capability to install libraries
192
+ Modified Directory tree, to better separate libraries from programs.
193
+
194
+ r110 :
195
+ lz4 & lz4hc : added capability to allocate state & stream state with custom allocator (issue 99)
196
+ fuzzer & fullbench : updated to test new functions
197
+ man : documented -l command (Legacy format, for Linux kernel compression) (issue 102)
198
+ cmake : improved version by Mika Attila, building programs and libraries (issue 100)
199
+ xxHash : updated to r33
200
+ Makefile : clean also delete local package .tar.gz
201
+
202
+ r109 :
203
+ lz4.c : corrected issue 98 (LZ4_compress_limitedOutput())
204
+ Makefile : can specify version number from makefile
205
+
206
+ r108 :
207
+ lz4.c : corrected compression efficiency issue 97 in 64-bits chained mode (-BD) for streams > 4 GB (thanks Roman Strashkin for reporting)
208
+
209
+ r107 :
210
+ Makefile : support DESTDIR for staged installs. Thanks Jorge Aparicio.
211
+ Makefile : make install installs both lz4 and lz4c (Jorge Aparicio)
212
+ Makefile : removed -Wno-implicit-declaration compilation switch
213
+ lz4cli.c : include <stduni.h> for isatty() (Luca Barbato)
214
+ lz4.h : introduced LZ4_MAX_INPUT_SIZE constant (Shay Green)
215
+ lz4.h : LZ4_compressBound() : unified macro and inline definitions (Shay Green)
216
+ lz4.h : LZ4_decompressSafe_partial() : clarify comments (Shay Green)
217
+ lz4.c : LZ4_compress() verify input size condition (Shay Green)
218
+ bench.c : corrected a bug in free memory size evaluation
219
+ cmake : install into bin/ directory (Richard Yao)
220
+ cmake : check for just C compiler (Elan Ruusamae)
221
+
222
+ r106 :
223
+ Makefile : make dist modify text files in the package to respect Unix EoL convention
224
+ lz4cli.c : corrected small display bug in HC mode
225
+
226
+ r105 :
227
+ Makefile : New install script and man page, contributed by Prasad Pandit
228
+ lz4cli.c : Minor modifications, for easier extensibility
229
+ COPYING : added license file
230
+ LZ4_Streaming_Format.odt : modified file name to remove white space characters
231
+ Makefile : .exe suffix now properly added only for Windows target