Module: XZ::LibLZMA
- Extended by:
- Fiddle::Importer, FiddleHelper
- Defined in:
- lib/xz/lib_lzma.rb
Overview
This module wraps functions and enums provided by liblzma. It contains the direct mapping to the underlying C functions; you should never have to use this. It’s the lowlevel API the other methods provided by ruby-xz are based on.
Constant Summary collapse
- UINT64_MAX =
The maximum value of an uint64_t, as defined by liblzma. Should be the same as
(2 ** 64) - 1
18446744073709551615
- LZMA_PRESET_EXTREME =
Activates extreme compression. Same as xz’s “-e” commandline switch.
1 << 31
- LZMA_TELL_NO_CHECK =
0x01
- LZMA_TELL_UNSUPPORTED_CHECK =
0x02
- LZMA_TELL_ANY_CHECK =
0x04
- LZMA_CONCATENATED =
0x08
- LZMA_IGNORE_CHECK =
0x10
- LZMA_DECODE_FLAGS =
For access convenience of the above flags.
{ :tell_no_check => LZMA_TELL_NO_CHECK, :tell_unsupported_check => LZMA_TELL_UNSUPPORTED_CHECK, :tell_any_check => LZMA_TELL_ANY_CHECK, :concatenated => LZMA_CONCATENATED, :ignore_check => LZMA_IGNORE_CHECK }.freeze
- LZMAStream =
lzma_stream struct. When creating one with ::malloc, use ::LZMA_STREAM_INIT to make it ready for use.
This is a Fiddle::CStruct. As such, this has a class method ::malloc for allocating an instance of it on the heap, and instances of it have a #to_ptr method that returns a Fiddle::Pointer. That pointer needs to be freed with Fiddle::free if the instance was created with ::malloc. To wrap an existing instance, call ::new with the Fiddle::Pointer to wrap as an argument.
struct [ "uint8_t* next_in", "size_t avail_in", "uint64_t total_in", "uint8_t* next_out", "size_t avail_out", "uint64_t total_out", "void* allocator", "void* internal", "void* reserved_ptr1", "void* reserved_ptr2", "void* reserved_ptr3", "void* reserved_ptr4", "uint64_t reserved_int1", "uint64_t reserved_int2", "size_t reserved_int3", "size_t reserved_int4", "lzma_reserved_enum reserved_enum1", "lzma_reserved_enum reserved_enum2" ]
Class Method Summary collapse
-
.LZMA_STREAM_INIT(stream) ⇒ Object
This method does basicly the same thing as the LZMA_STREAM_INIT macro of liblzma.
Methods included from FiddleHelper
Class Method Details
.LZMA_STREAM_INIT(stream) ⇒ Object
This method does basicly the same thing as the LZMA_STREAM_INIT macro of liblzma. Pass it an instance of LZMAStream that has not been initialised for use. The intended use of this method is:
stream = LibLZMA::LZMAStream.malloc # ::malloc is provided by fiddle
LibLZMA.LZMA_STREAM_INIT(stream)
# ...do something with the stream...
Fiddle.free(stream.to_ptr)
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/xz/lib_lzma.rb', line 132 def self.LZMA_STREAM_INIT(stream) stream.next_in = nil stream.avail_in = 0 stream.total_in = 0 stream.next_out = nil stream.avail_out = 0 stream.total_out = 0 stream.allocator = nil stream.internal = nil stream.reserved_ptr1 = nil stream.reserved_ptr2 = nil stream.reserved_ptr3 = nil stream.reserved_ptr4 = nil stream.reserved_int1 = 0 stream.reserved_int2 = 0 stream.reserved_int3 = 0 stream.reserved_int4 = 0 stream.reserved_enum1 = LZMA_RESERVED_ENUM stream.reserved_enum2 = LZMA_RESERVED_ENUM stream end |