Module Lzma

module Lzma: sig .. end

OCaml bindings to the lzma library


You can get more documentation reading the comments in the files /usr/include/lzma/*.h

exception EOF of int
exception MEM_LIMIT of int64

memory usage limit was reached, the minimum required mem-limit value is returned

val init : unit -> unit
type lzma_stream 
val new_lzma_stream : unit -> lzma_stream
val lzma_stream_total_in_out : strm:lzma_stream -> int64 * int64

total number of bytes read/written by liblzma

Type of the integrity check (Check ID)

type lzma_check = 
| LZMA_CHECK_NONE (*

No Check is calculated. (size of the Check field: 0 bytes)

*)
| LZMA_CHECK_CRC32 (*

CRC32 using the polynomial from the IEEE 802.3 standard (Size of the Check field: 4 bytes)

*)
| LZMA_CHECK_CRC64 (*

CRC64 using the polynomial from the ECMA-182 standard (Size of the Check field: 8 bytes)

*)
| LZMA_CHECK_SHA256 (*

SHA-256 (Size of the Check field: 32 bytes)

*)

The .xz format supports multiple types of checks that are calculated from the uncompressed data. They vary in both speed and ability to detect errors.

Initialise for decoding

val lzma_auto_decoder : strm:lzma_stream -> memlimit:int64 -> check:lzma_check -> unit

decode .xz streams and .lzma streams with autodetection

Initialise for encoding

type lzma_preset = 
| LZMA_PRESET_DEFAULT
| LZMA_PRESET_EXTREME
| LZMA_PRESET_TEXT
val lzma_easy_encoder : strm:lzma_stream ->
level:int -> preset:lzma_preset list -> check:lzma_check -> unit

initialise .xz stream encoder

type lzma_options 
val new_lzma_options : unit -> lzma_options
val lzma_preset : options:lzma_options -> level:int -> preset_extreme:bool -> unit
val lzma_alone_encoder : strm:lzma_stream -> options:lzma_options -> unit

initialise .lzma stream encoder

Running encoding/decoding

type lzma_action = 
| LZMA_RUN
| LZMA_SYNC_FLUSH
| LZMA_FULL_FLUSH
| LZMA_FINISH
val lzma_code : strm:lzma_stream ->
action:lzma_action ->
next_in:string -> next_out:string -> ofs_in:int -> ofs_out:int -> int * int

returns (avail_in, avail_out)

Ending

val lzma_end : strm:lzma_stream -> unit

Single-call

val lzma_stream_buffer_bound : uncompressed_size:int -> int

Calculate output buffer size for single-call Stream encoder

val lzma_easy_buffer_encode : level:int ->
preset:lzma_preset list ->
check:lzma_check -> data:string -> buf:string -> ofs:int -> int

single-call .xz stream encoding

type decoder_flags = 
| LZMA_TELL_NO_CHECK
| LZMA_TELL_UNSUPPORTED_CHECK
| LZMA_CONCATENATED
val lzma_stream_buffer_decode : memlimit:int64 ->
flags:decoder_flags list ->
data:string -> data_ofs:int -> buf:string -> buf_ofs:int -> int * int

single-call .xz stream decoder returns (in_pos, out_pos)

Version

type stability = 
| Alpha
| Beta
| Stable
type version_kind = 
| Run_time
| Compile_time
val lzma_version_number : version_kind -> int * int * int * stability
val lzma_version_string : version_kind -> string