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

Functions for reading and parsing of MOBI document. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "read.h"
#include "util.h"
#include "index.h"
#include "debug.h"

Functions

MOBI_RET mobi_load_pdbheader (MOBIData *m, FILE *file)
 Read palm database header from file into MOBIData structure (MOBIPdbHeader) More...
 
MOBI_RET mobi_load_reclist (MOBIData *m, FILE *file)
 Read list of database records from file into MOBIData structure (MOBIPdbRecord) More...
 
MOBI_RET mobi_load_rec (MOBIData *m, FILE *file)
 Read record data and size from file into MOBIData structure (MOBIPdbRecord) More...
 
MOBI_RET mobi_load_recdata (MOBIPdbRecord *rec, FILE *file)
 Read record data from file into MOBIPdbRecord structure. More...
 
MOBI_RET mobi_parse_extheader (MOBIData *m, MOBIBuffer *buf)
 Parse EXTH header from Record 0 into MOBIData structure (MOBIExthHeader) More...
 
MOBI_RET mobi_parse_mobiheader (MOBIData *m, MOBIBuffer *buf)
 Parse MOBI header from Record 0 into MOBIData structure (MOBIMobiHeader) More...
 
MOBI_RET mobi_parse_record0 (MOBIData *m, const size_t seqnumber)
 Parse Record 0 into MOBIData structure. More...
 
size_t mobi_get_record_extrasize (const MOBIPdbRecord *record, const uint16_t flags)
 Calculate the size of extra bytes at the end of text record. More...
 
size_t mobi_get_record_mb_extrasize (const MOBIPdbRecord *record, const uint16_t flags)
 Calculate the size of extra multibyte section at the end of text record. More...
 
MOBI_RET mobi_parse_huff (MOBIHuffCdic *huffcdic, const MOBIPdbRecord *record)
 Parse HUFF record into MOBIHuffCdic structure. More...
 
MOBI_RET mobi_parse_cdic (MOBIHuffCdic *huffcdic, const MOBIPdbRecord *record, const size_t num)
 Parse CDIC record into MOBIHuffCdic structure. More...
 
MOBI_RET mobi_parse_huffdic (const MOBIData *m, MOBIHuffCdic *huffcdic)
 Parse a set of HUFF and CDIC records into MOBIHuffCdic structure. More...
 
MOBI_RET mobi_parse_fdst (const MOBIData *m, MOBIRawml *rawml)
 Parse FDST record into MOBIRawml structure (MOBIFdst member) More...
 
MOBI_RET mobi_load_file (MOBIData *m, FILE *file)
 Read MOBI document from file into MOBIData structure. More...
 
MOBI_RET mobi_load_filename (MOBIData *m, const char *path)
 Read MOBI document from a path into MOBIData structure. More...
 

Detailed Description

Functions for reading and parsing of MOBI document.

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_load_pdbheader()

MOBI_RET mobi_load_pdbheader ( MOBIData m,
FILE *  file 
)

Read palm database header from file into MOBIData structure (MOBIPdbHeader)

Parameters
[in,out]mMOBIData structure to be filled with read data
[in]fileFiledescriptor to read from
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_load_rec()

MOBI_RET mobi_load_rec ( MOBIData m,
FILE *  file 
)

Read record data and size from file into MOBIData structure (MOBIPdbRecord)

Parameters
[in,out]mMOBIData structure to be filled with read data
[in]fileFiledescriptor to read from
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_load_recdata()

MOBI_RET mobi_load_recdata ( MOBIPdbRecord rec,
FILE *  file 
)

Read record data from file into MOBIPdbRecord structure.

Parameters
[in,out]recMOBIPdbRecord structure to be filled with read data
[in]fileFiledescriptor to read from
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_load_reclist()

MOBI_RET mobi_load_reclist ( MOBIData m,
FILE *  file 
)

Read list of database records from file into MOBIData structure (MOBIPdbRecord)

Parameters
[in,out]mMOBIData structure to be filled with read data
[in]fileFiledescriptor to read from
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_cdic()

MOBI_RET mobi_parse_cdic ( MOBIHuffCdic huffcdic,
const MOBIPdbRecord record,
const size_t  num 
)

Parse CDIC record into MOBIHuffCdic structure.

Parameters
[in,out]huffcdicMOBIHuffCdic structure to be filled with parsed data
[in]recordMOBIPdbRecord structure containing the record
[in]numNumber of CDIC record in a set, starting from zero
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_extheader()

MOBI_RET mobi_parse_extheader ( MOBIData m,
MOBIBuffer buf 
)

Parse EXTH header from Record 0 into MOBIData structure (MOBIExthHeader)

Parameters
[in,out]mMOBIData structure to be filled with parsed data
[in]bufMOBIBuffer buffer to read from
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_fdst()

MOBI_RET mobi_parse_fdst ( const MOBIData m,
MOBIRawml rawml 
)

Parse FDST record into MOBIRawml structure (MOBIFdst member)

Parameters
[in]mMOBIData structure with loaded MOBI document
[in,out]rawmlMOBIRawml structure to be filled with parsed data
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_huff()

MOBI_RET mobi_parse_huff ( MOBIHuffCdic huffcdic,
const MOBIPdbRecord record 
)

Parse HUFF record into MOBIHuffCdic structure.

Parameters
[in,out]huffcdicMOBIHuffCdic structure to be filled with parsed data
[in]recordMOBIPdbRecord structure containing the record
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_huffdic()

MOBI_RET mobi_parse_huffdic ( const MOBIData m,
MOBIHuffCdic huffcdic 
)

Parse a set of HUFF and CDIC records into MOBIHuffCdic structure.

Parameters
[in]mMOBIData structure with loaded MOBI document
[in,out]huffcdicMOBIHuffCdic structure to be filled with parsed data
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_mobiheader()

MOBI_RET mobi_parse_mobiheader ( MOBIData m,
MOBIBuffer buf 
)

Parse MOBI header from Record 0 into MOBIData structure (MOBIMobiHeader)

Parameters
[in,out]mMOBIData structure to be filled with parsed data
[in]bufMOBIBuffer buffer to read from
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_record0()

MOBI_RET mobi_parse_record0 ( MOBIData m,
const size_t  seqnumber 
)

Parse Record 0 into MOBIData structure.

This function will parse MOBIRecord0Header, MOBIMobiHeader and MOBIExthHeader

Parameters
[in,out]mMOBIData structure to be filled with parsed data
[in]seqnumberSequential number of the palm database record
Returns
MOBI_RET status code (on success MOBI_SUCCESS)