module XZ::LibLZMA

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.

Constants

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.

LZMA_CONCATENATED
LZMA_DECODE_FLAGS

For access convenience of the above flags.

LZMA_IGNORE_CHECK
LZMA_PRESET_EXTREME

Activates extreme compression. Same as xz's ā€œ-eā€ commandline switch.

LZMA_TELL_ANY_CHECK
LZMA_TELL_NO_CHECK
LZMA_TELL_UNSUPPORTED_CHECK
UINT64_MAX

The maximum value of an uint64_t, as defined by liblzma. Should be the same as

(2 ** 64) - 1

Public Class Methods

LZMA_STREAM_INIT(stream) click to toggle source

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)
# File lib/xz/lib_lzma.rb, line 131
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