libmobi
C library for handling MOBI format ebook documents
Functions
compression.c File Reference

Functions handling compression. More...

#include <string.h>
#include "compression.h"
#include "buffer.h"
#include "mobi.h"
#include "debug.h"

Functions

MOBI_RET mobi_decompress_lz77 (unsigned char *out, const unsigned char *in, size_t *len_out, const size_t len_in)
 Decompressor fo PalmDOC version of LZ77 compression. More...
 
MOBI_RET mobi_decompress_huffman (unsigned char *out, const unsigned char *in, size_t *len_out, size_t len_in, const MOBIHuffCdic *huffcdic)
 Decompressor for huff/cdic compressed text records. More...
 

Detailed Description

Functions handling compression.

Copyright (c) 2014 Bartek Fabiszewski http://www.fabiszewski.net

This file is part of libmobi. Licensed under LGPL, either version 3, or any later. See http://www.gnu.org/licenses/

Function Documentation

◆ mobi_decompress_huffman()

MOBI_RET mobi_decompress_huffman ( unsigned char *  out,
const unsigned char *  in,
size_t *  len_out,
size_t  len_in,
const MOBIHuffCdic huffcdic 
)

Decompressor for huff/cdic compressed text records.

Decompressor and HUFF/CDIC records parsing based on: perl EBook::Tools::Mobipocket python mobiunpack.py, calibre

Parameters
[out]outDecompressed destination data
[in]inCompressed source data
[in,out]len_outSize of the memory reserved for decompressed data. On return it is set to actual size of decompressed data
[in]len_inSize of compressed data
[in]huffcdicMOBIHuffCdic structure with parsed data from huff/cdic records
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_decompress_lz77()

MOBI_RET mobi_decompress_lz77 ( unsigned char *  out,
const unsigned char *  in,
size_t *  len_out,
const size_t  len_in 
)

Decompressor fo PalmDOC version of LZ77 compression.

Decompressor based on this algorithm: http://en.wikibooks.org/wiki/Data_Compression/Dictionary_compression#PalmDoc

Parameters
[out]outDecompressed destination data
[in]inCompressed source data
[in,out]len_outSize of the memory reserved for decompressed data. On return it is set to actual size of decompressed data
[in]len_inSize of compressed data
Returns
MOBI_RET status code (on success MOBI_SUCCESS)