libmobi
C library for handling MOBI format ebook documents
Functions
Functions exported by the library

Functions

MOBI_EXPORT const char * mobi_version (void)
 Get libmobi version. More...
 
MOBI_EXPORT MOBI_RET mobi_load_file (MOBIData *m, FILE *file)
 Read MOBI document from file into MOBIData structure. More...
 
MOBI_EXPORT MOBI_RET mobi_load_filename (MOBIData *m, const char *path)
 Read MOBI document from a path into MOBIData structure. More...
 
MOBI_EXPORT MOBIDatamobi_init (void)
 Initializer for MOBIData structure. More...
 
MOBI_EXPORT void mobi_free (MOBIData *m)
 Free MOBIData structure and all its children. More...
 
MOBI_EXPORT MOBI_RET mobi_parse_kf7 (MOBIData *m)
 Loader will parse KF7 part of hybrid file. More...
 
MOBI_EXPORT MOBI_RET mobi_parse_kf8 (MOBIData *m)
 Loader will parse KF8 part of hybrid file. More...
 
MOBI_EXPORT MOBI_RET mobi_parse_rawml (MOBIRawml *rawml, const MOBIData *m)
 Parse raw records into html flow parts, markup parts, resources and indices. More...
 
MOBI_EXPORT MOBI_RET mobi_parse_rawml_opt (MOBIRawml *rawml, const MOBIData *m, bool parse_toc, bool parse_dict, bool reconstruct)
 Parse raw records into html flow parts, markup parts, resources and indices. Individual stages of the parsing may be turned on/off. More...
 
MOBI_EXPORT MOBI_RET mobi_get_rawml (const MOBIData *m, char *text, size_t *len)
 Decompress text to a text buffer. More...
 
MOBI_EXPORT MOBI_RET mobi_dump_rawml (const MOBIData *m, FILE *file)
 Decompress text record to an open file descriptor. More...
 
MOBI_EXPORT MOBI_RET mobi_decode_font_resource (unsigned char **decoded_font, size_t *decoded_size, MOBIPart *part)
 Deobfuscator and decompressor for font resources. More...
 
MOBI_EXPORT MOBI_RET mobi_decode_audio_resource (unsigned char **decoded_resource, size_t *decoded_size, MOBIPart *part)
 Decode audio resource. More...
 
MOBI_EXPORT MOBI_RET mobi_decode_video_resource (unsigned char **decoded_resource, size_t *decoded_size, MOBIPart *part)
 Decode video resource. More...
 
MOBI_EXPORT MOBI_RET mobi_get_embedded_source (unsigned char **data, size_t *size, const MOBIData *m)
 Get embedded source archive. More...
 
MOBI_EXPORT MOBI_RET mobi_get_embedded_log (unsigned char **data, size_t *size, const MOBIData *m)
 Get embedded conversion log. More...
 
MOBI_EXPORT MOBIPdbRecordmobi_get_record_by_uid (const MOBIData *m, const size_t uid)
 Get palm database record with given unique id. More...
 
MOBI_EXPORT MOBIPdbRecordmobi_get_record_by_seqnumber (const MOBIData *m, const size_t uid)
 Get palm database record with given sequential number (first record has number 0) More...
 
MOBI_EXPORT MOBIPartmobi_get_flow_by_uid (const MOBIRawml *rawml, const size_t uid)
 Get rawml->flow MOBIPart part by uid. More...
 
MOBI_EXPORT MOBIPartmobi_get_flow_by_fid (const MOBIRawml *rawml, const char *fid)
 Find flow part by flow id (fid) from kindle:flow:fid link. Flow fid is base32 encoded part uid. More...
 
MOBI_EXPORT MOBIPartmobi_get_resource_by_uid (const MOBIRawml *rawml, const size_t uid)
 Get MOBIPart resource record with given unique id. More...
 
MOBI_EXPORT MOBIPartmobi_get_resource_by_fid (const MOBIRawml *rawml, const char *fid)
 Find resource by flow id (fid) from kindle:embed:fid link. Flow fid is base32 encoded part uid. More...
 
MOBI_EXPORT MOBIPartmobi_get_part_by_uid (const MOBIRawml *rawml, const size_t uid)
 Get rawml->markup MOBIPart part by uid. More...
 
MOBI_EXPORT MOBI_RET mobi_get_fullname (const MOBIData *m, char *fullname, const size_t len)
 Get ebook full name stored in Record 0 at offset given in MOBI header. More...
 
MOBI_EXPORT size_t mobi_get_first_resource_record (const MOBIData *m)
 Get sequential number of first resource record (image/font etc) More...
 
MOBI_EXPORT size_t mobi_get_text_maxsize (const MOBIData *m)
 Get maximal size of all uncompressed text records. More...
 
MOBI_EXPORT uint16_t mobi_get_textrecord_maxsize (const MOBIData *m)
 Get maximal size of uncompressed text record. More...
 
MOBI_EXPORT size_t mobi_get_kf8offset (const MOBIData *m)
 Get offset of KF8 Boundary for KF7/KF8 hybrid file cached in MOBIData structure. More...
 
MOBI_EXPORT size_t mobi_get_kf8boundary_seqnumber (const MOBIData *m)
 Get sequential number of KF8 Boundary record for KF7/KF8 hybrid file. More...
 
MOBI_EXPORT 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...
 
MOBI_EXPORT 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_EXPORT size_t mobi_get_fileversion (const MOBIData *m)
 Get mobi file version. More...
 
MOBI_EXPORT size_t mobi_get_fdst_record_number (const MOBIData *m)
 Get sequential number of FDST record. More...
 
MOBI_EXPORT MOBIExthHeadermobi_get_exthrecord_by_tag (const MOBIData *m, const MOBIExthTag tag)
 Get EXTH record with given MOBIExthTag tag. More...
 
MOBI_EXPORT MOBIExthHeadermobi_next_exthrecord_by_tag (const MOBIData *m, const MOBIExthTag tag, MOBIExthHeader **start)
 Get EXTH record with given MOBIExthTag tag. Start list search at given record. More...
 
MOBI_EXPORT MOBI_RET mobi_delete_exthrecord_by_tag (MOBIData *m, const MOBIExthTag tag)
 Delete all EXTH records with given MOBIExthTag tag. More...
 
MOBI_EXPORT MOBI_RET mobi_add_exthrecord (MOBIData *m, const MOBIExthTag tag, const uint32_t size, const void *value)
 Add new EXTH record with given tag and value. More...
 
MOBI_EXPORT MOBIExthMeta mobi_get_exthtagmeta_by_tag (const MOBIExthTag tag)
 Get MOBIExthMeta tag structure by MOBIExthTag tag id. More...
 
MOBI_EXPORT MOBIFileMeta mobi_get_filemeta_by_type (const MOBIFiletype type)
 Get MOBIFileMeta tag structure by MOBIFiletype type. More...
 
MOBI_EXPORT uint32_t mobi_decode_exthvalue (const unsigned char *data, const size_t size)
 Decode big-endian value stored in EXTH record. More...
 
MOBI_EXPORT char * mobi_decode_exthstring (const MOBIData *m, const unsigned char *data, const size_t size)
 Decode string stored in EXTH record. More...
 
MOBI_EXPORT struct tm * mobi_pdbtime_to_time (const long pdb_time)
 Convert time values from palmdoc header to time tm struct. More...
 
MOBI_EXPORT const char * mobi_get_locale_string (const uint32_t locale)
 Get pointer to locale tag for a given Mobipocket locale number. More...
 
MOBI_EXPORT size_t mobi_get_locale_number (const char *locale_string)
 Get Mobipocket locale number for a given string tag. More...
 
MOBI_EXPORT uint32_t mobi_get_orth_entry_offset (const MOBIIndexEntry *entry)
 Get entry start offset for the orth entry. More...
 
MOBI_EXPORT uint32_t mobi_get_orth_entry_length (const MOBIIndexEntry *entry)
 Get text length for the orth entry. More...
 
MOBI_EXPORT MOBI_RET mobi_remove_hybrid_part (MOBIData *m, const bool remove_kf8)
 Remove one version from hybrid file. More...
 
MOBI_EXPORT bool mobi_exists_mobiheader (const MOBIData *m)
 Check if MOBI header is loaded / present in the loaded file. More...
 
MOBI_EXPORT bool mobi_exists_fdst (const MOBIData *m)
 Check if FDST record is present in the loaded file. More...
 
MOBI_EXPORT bool mobi_exists_skel_indx (const MOBIData *m)
 Check if skeleton INDX is present in the loaded file. More...
 
MOBI_EXPORT bool mobi_exists_frag_indx (const MOBIData *m)
 Check if fragments INDX is present in the loaded file. More...
 
MOBI_EXPORT bool mobi_exists_guide_indx (const MOBIData *m)
 Check if guide INDX is present in the loaded file. More...
 
MOBI_EXPORT bool mobi_exists_ncx (const MOBIData *m)
 Check if ncx INDX is present in the loaded file. More...
 
MOBI_EXPORT bool mobi_exists_orth (const MOBIData *m)
 Check if orth INDX is present in the loaded file. More...
 
MOBI_EXPORT bool mobi_exists_infl (const MOBIData *m)
 Check if infl INDX is present in the loaded file. More...
 
MOBI_EXPORT bool mobi_is_hybrid (const MOBIData *m)
 Check if loaded MOBI data is KF7/KF8 hybrid file. More...
 
MOBI_EXPORT bool mobi_is_encrypted (const MOBIData *m)
 Check if loaded document is encrypted. More...
 
MOBI_EXPORT bool mobi_is_mobipocket (const MOBIData *m)
 Check if loaded document is MOBI/BOOK Mobipocket format. More...
 
MOBI_EXPORT bool mobi_is_dictionary (const MOBIData *m)
 Check if loaded document is dictionary. More...
 
MOBI_EXPORT bool mobi_is_kf8 (const MOBIData *m)
 Is file version 8 or above. More...
 
MOBI_EXPORT bool mobi_is_replica (const MOBIData *m)
 Check if loaded document is Print Replica type. More...
 
MOBI_EXPORT bool mobi_is_rawml_kf8 (const MOBIRawml *rawml)
 Is file version 8 or above. More...
 
MOBI_EXPORT MOBIRawmlmobi_init_rawml (const MOBIData *m)
 Initialize and return MOBIRawml structure. More...
 
MOBI_EXPORT void mobi_free_rawml (MOBIRawml *rawml)
 Free MOBIRawml structure allocated by mobi_init_rawml() More...
 
MOBI_EXPORT char * mobi_meta_get_title (const MOBIData *m)
 Get document title metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_author (const MOBIData *m)
 Get document author metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_publisher (const MOBIData *m)
 Get document publisher metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_imprint (const MOBIData *m)
 Get document imprint metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_description (const MOBIData *m)
 Get document description metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_isbn (const MOBIData *m)
 Get document ISBN metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_subject (const MOBIData *m)
 Get document subject metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_publishdate (const MOBIData *m)
 Get document publishing date metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_review (const MOBIData *m)
 Get document review metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_contributor (const MOBIData *m)
 Get document contributor metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_copyright (const MOBIData *m)
 Get document copyright metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_asin (const MOBIData *m)
 Get document ASIN metadata. More...
 
MOBI_EXPORT char * mobi_meta_get_language (const MOBIData *m)
 Get document language code metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_title (MOBIData *m, const char *title)
 Set document title metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_title (MOBIData *m, const char *title)
 Add document title metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_title (MOBIData *m)
 Delete all title metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_author (MOBIData *m, const char *author)
 Set document author metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_author (MOBIData *m, const char *author)
 Add document author metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_author (MOBIData *m)
 Delete all author metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_publisher (MOBIData *m, const char *publisher)
 Set document publisher metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_publisher (MOBIData *m, const char *publisher)
 Add document publisher metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_publisher (MOBIData *m)
 Delete all publisher metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_imprint (MOBIData *m, const char *imprint)
 Set document imprint metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_imprint (MOBIData *m, const char *imprint)
 Add document imprint metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_imprint (MOBIData *m)
 Delete all imprint metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_description (MOBIData *m, const char *description)
 Set document description metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_description (MOBIData *m, const char *description)
 Add document description metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_description (MOBIData *m)
 Delete all description metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_isbn (MOBIData *m, const char *isbn)
 Set document isbn metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_isbn (MOBIData *m, const char *isbn)
 Add document isbn metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_isbn (MOBIData *m)
 Delete all isbn metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_subject (MOBIData *m, const char *subject)
 Set document subject metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_subject (MOBIData *m, const char *subject)
 Add document subject metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_subject (MOBIData *m)
 Delete all subject metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_publishdate (MOBIData *m, const char *publishdate)
 Set document publishdate metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_publishdate (MOBIData *m, const char *publishdate)
 Add document publishdate metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_publishdate (MOBIData *m)
 Delete all publishdate metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_review (MOBIData *m, const char *review)
 Set document review metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_review (MOBIData *m, const char *review)
 Add document review metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_review (MOBIData *m)
 Delete all review metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_contributor (MOBIData *m, const char *contributor)
 Set document contributor metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_contributor (MOBIData *m, const char *contributor)
 Add document contributor metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_contributor (MOBIData *m)
 Delete all contributor metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_copyright (MOBIData *m, const char *copyright)
 Set document copyright metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_copyright (MOBIData *m, const char *copyright)
 Add document copyright metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_copyright (MOBIData *m)
 Delete all copyright metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_asin (MOBIData *m, const char *asin)
 Set document asin metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_asin (MOBIData *m, const char *asin)
 Add document asin metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_asin (MOBIData *m)
 Delete all asin metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_set_language (MOBIData *m, const char *language)
 Set document language code metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_add_language (MOBIData *m, const char *language)
 Add document language code metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_meta_delete_language (MOBIData *m)
 Delete all language code metadata. More...
 
MOBI_EXPORT MOBI_RET mobi_drm_setkey (MOBIData *m, const char *pid)
 Store PID for encryption in MOBIData stucture. More...
 
MOBI_EXPORT MOBI_RET mobi_drm_setkey_serial (MOBIData *m, const char *serial)
 Store PID for encryption in MOBIData stucture. PID will be calculated from device serial number. More...
 
MOBI_EXPORT MOBI_RET mobi_drm_addvoucher (MOBIData *m, const char *serial, const time_t valid_from, const time_t valid_to, const MOBIExthTag *tamperkeys, const size_t tamperkeys_count)
 Add DRM voucher. More...
 
MOBI_EXPORT MOBI_RET mobi_drm_delkey (MOBIData *m)
 Remove PID stored for encryption from MOBIData structure. More...
 
MOBI_EXPORT MOBI_RET mobi_drm_decrypt (MOBIData *m)
 Decrypt document. More...
 
MOBI_EXPORT MOBI_RET mobi_drm_encrypt (MOBIData *m)
 Encrypt document. More...
 
MOBI_EXPORT MOBI_RET mobi_write_file (FILE *file, MOBIData *m)
 Write mobi document to file. More...
 

Detailed Description

Function Documentation

◆ mobi_add_exthrecord()

MOBI_EXPORT MOBI_RET mobi_add_exthrecord ( MOBIData m,
const MOBIExthTag  tag,
const uint32_t  size,
const void *  value 
)

Add new EXTH record with given tag and value.

Parameters
[in,out]mMOBIData structure with loaded data
[in]tagMOBIExthTag EXTH record tag
[in]sizeValue size
[in]valueValue
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobimeta.c.

◆ mobi_decode_audio_resource()

MOBI_EXPORT MOBI_RET mobi_decode_audio_resource ( unsigned char **  decoded_resource,
size_t *  decoded_size,
MOBIPart part 
)

Decode audio resource.

Parameters
[in,out]decoded_resourcePointer to data offset in mobipocket record.
[in,out]decoded_sizeDecoded resource data size
[in,out]partMOBIPart structure containing resource, decoded part type will be set in the structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_decode_exthstring()

MOBI_EXPORT char* mobi_decode_exthstring ( const MOBIData m,
const unsigned char *  data,
const size_t  size 
)

Decode string stored in EXTH record.

Only for EXTH records storing string values

Parameters
[in]mMOBIData structure loaded with MOBI data
[in]dataMemory area storing EXTH record data
[in]sizeSize of EXTH record data
Returns
String from EXTH record in utf-8 encoding
Examples
common.c.

◆ mobi_decode_exthvalue()

MOBI_EXPORT uint32_t mobi_decode_exthvalue ( const unsigned char *  data,
const size_t  size 
)

Decode big-endian value stored in EXTH record.

Only for EXTH records storing numeric values

Parameters
[in]dataMemory area storing EXTH record data
[in]sizeSize of EXTH record data
Returns
32-bit value
Examples
common.c, and mobitool.c.

◆ mobi_decode_font_resource()

MOBI_EXPORT MOBI_RET mobi_decode_font_resource ( unsigned char **  decoded_font,
size_t *  decoded_size,
MOBIPart part 
)

Deobfuscator and decompressor for font resources.

Parameters
[in,out]decoded_fontPointer to memory to write to. Will be allocated. Must be freed by caller
[in,out]decoded_sizeDecoded font data size
[in,out]partMOBIPart structure containing font resource, decoded part type will be set in the structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_decode_video_resource()

MOBI_EXPORT MOBI_RET mobi_decode_video_resource ( unsigned char **  decoded_resource,
size_t *  decoded_size,
MOBIPart part 
)

Decode video resource.

Parameters
[in,out]decoded_resourcePointer to data offset in mobipocket record.
[in,out]decoded_sizeDecoded resource data size
[in,out]partMOBIPart structure containing resource, decoded part type will be set in the structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_delete_exthrecord_by_tag()

MOBI_EXPORT MOBI_RET mobi_delete_exthrecord_by_tag ( MOBIData m,
const MOBIExthTag  tag 
)

Delete all EXTH records with given MOBIExthTag tag.

Parameters
[in,out]mMOBIData structure with loaded data
[in]tagMOBIExthTag EXTH record tag
Returns
Pointer to MOBIExthHeader record structure
Examples
mobimeta.c.

◆ mobi_drm_addvoucher()

MOBI_EXPORT MOBI_RET mobi_drm_addvoucher ( MOBIData m,
const char *  serial,
const time_t  valid_from,
const time_t  valid_to,
const MOBIExthTag tamperkeys,
const size_t  tamperkeys_count 
)

Add DRM voucher.

DRM vouncher will be used to generate pid key which is used to encrypt main encryption key. Pid key is based on device serial number. Optionally it is possible to set validity of the key. The key will be valid only within the period. Optionally the pid key may be generated not only from serial number but also from contents of selected EXTH headers. In such case the headers should be added (

See also
mobi_add_exthrecord) before calling this function and array of header tags passed as function parameter.
Parameters
[in,out]mMOBIData structure with raw data and metadata
[in]serialDevice serial number
[in]valid_fromDRM validity start time, -1 if not set
[in]valid_toDRM validity end time, -1 if not set
[in]tamperkeysArray of EXTH tags to include in PID generation, NULL if none
[in]tamperkeys_countCount of EXTH tags
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_drm_decrypt()

MOBI_EXPORT MOBI_RET mobi_drm_decrypt ( MOBIData m)

Decrypt document.

It is not necessary to call this function in order to parse encrypted document. If pid is set document will be decrypted automatically during uncompression. The reason for this function is to load and resave decrypted document without parsing.

Parameters
[in,out]mMOBIData structure with raw data and metadata
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_drm_delkey()

MOBI_EXPORT MOBI_RET mobi_drm_delkey ( MOBIData m)

Remove PID stored for encryption from MOBIData structure.

Parameters
[in,out]mMOBIData structure with raw data and metadata
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_drm_encrypt()

MOBI_EXPORT MOBI_RET mobi_drm_encrypt ( MOBIData m)

Encrypt document.

DRM vouchers must be added in order to use device serial number in encryption

Parameters
[in,out]mMOBIData structure with raw data and metadata
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_drm_setkey()

MOBI_EXPORT MOBI_RET mobi_drm_setkey ( MOBIData m,
const char *  pid 
)

Store PID for encryption in MOBIData stucture.

Parameters
[in,out]mMOBIData structure with raw data and metadata
[in]pidPID
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
common.c.

◆ mobi_drm_setkey_serial()

MOBI_EXPORT MOBI_RET mobi_drm_setkey_serial ( MOBIData m,
const char *  serial 
)

Store PID for encryption in MOBIData stucture. PID will be calculated from device serial number.

Parameters
[in,out]mMOBIData structure with raw data and metadata
[in]serialDevice serial number
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
common.c.

◆ mobi_dump_rawml()

MOBI_EXPORT MOBI_RET mobi_dump_rawml ( const MOBIData m,
FILE *  file 
)

Decompress text record to an open file descriptor.

Internal function for mobi_get_rawml and mobi_dump_rawml. Decompressed output is stored either in a file or in a text string

Parameters
[in]mMOBIData structure loaded with MOBI data
[in,out]fileFile descriptor
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobitool.c.

◆ mobi_exists_fdst()

MOBI_EXPORT bool mobi_exists_fdst ( const MOBIData m)

Check if FDST record is present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_exists_frag_indx()

MOBI_EXPORT bool mobi_exists_frag_indx ( const MOBIData m)

Check if fragments INDX is present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_exists_guide_indx()

MOBI_EXPORT bool mobi_exists_guide_indx ( const MOBIData m)

Check if guide INDX is present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_exists_infl()

MOBI_EXPORT bool mobi_exists_infl ( const MOBIData m)

Check if infl INDX is present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_exists_mobiheader()

MOBI_EXPORT bool mobi_exists_mobiheader ( const MOBIData m)

Check if MOBI header is loaded / present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_exists_ncx()

MOBI_EXPORT bool mobi_exists_ncx ( const MOBIData m)

Check if ncx INDX is present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_exists_orth()

MOBI_EXPORT bool mobi_exists_orth ( const MOBIData m)

Check if orth INDX is present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_exists_skel_indx()

MOBI_EXPORT bool mobi_exists_skel_indx ( const MOBIData m)

Check if skeleton INDX is present in the loaded file.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
true on success, false otherwise

◆ mobi_free()

MOBI_EXPORT void mobi_free ( MOBIData m)

Free MOBIData structure and all its children.

Parameters
[in]mMOBIData structure

◆ mobi_free_rawml()

MOBI_EXPORT void mobi_free_rawml ( MOBIRawml rawml)

Free MOBIRawml structure allocated by mobi_init_rawml()

Pointer to data may point to memory area also used by record->data. So we need a flag to leave the memory allocated, while freeing MOBIPart structure

Parameters
[in]rawmlMOBIRawml structure

◆ mobi_get_embedded_log()

MOBI_EXPORT MOBI_RET mobi_get_embedded_log ( unsigned char **  data,
size_t *  size,
const MOBIData m 
)

Get embedded conversion log.

Some mobi creator software store original conversion log together with source archive. The function may return MOBI_SUCCESS even if the data was not found, so it is neccessary to check whether returned data pointer is not NULL.

Parameters
[in,out]dataPointer to data offset in pdb record.
[in,out]sizePointer to data size
[in]mMOBIData structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobitool.c.

◆ mobi_get_embedded_source()

MOBI_EXPORT MOBI_RET mobi_get_embedded_source ( unsigned char **  data,
size_t *  size,
const MOBIData m 
)

Get embedded source archive.

Some mobi creator software store original conversion source as a zip archive. The function may return MOBI_SUCCESS even if the data was not found, so it is neccessary to check whether returned data pointer is not NULL.

Parameters
[in,out]dataPointer to data offset in pdb record.
[in,out]sizePointer to data size
[in]mMOBIData structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobitool.c.

◆ mobi_get_exthrecord_by_tag()

MOBI_EXPORT MOBIExthHeader* mobi_get_exthrecord_by_tag ( const MOBIData m,
const MOBIExthTag  tag 
)

Get EXTH record with given MOBIExthTag tag.

Parameters
[in]mMOBIData structure with loaded data
[in]tagMOBIExthTag EXTH record tag
Returns
Pointer to MOBIExthHeader record structure
Examples
common.c, and mobitool.c.

◆ mobi_get_exthtagmeta_by_tag()

MOBI_EXPORT MOBIExthMeta mobi_get_exthtagmeta_by_tag ( const MOBIExthTag  tag)

Get MOBIExthMeta tag structure by MOBIExthTag tag id.

Parameters
[in]tagTag id
Returns
MOBIExthMeta structure for given tag id, zeroed structure on failure
Examples
common.c, and mobimeta.c.

◆ mobi_get_fdst_record_number()

MOBI_EXPORT size_t mobi_get_fdst_record_number ( const MOBIData m)

Get sequential number of FDST record.

Parameters
[in]mMOBIData structure loaded with MOBI data
Returns
Record number on success, MOBI_NOTSET otherwise

◆ mobi_get_filemeta_by_type()

MOBI_EXPORT MOBIFileMeta mobi_get_filemeta_by_type ( const MOBIFiletype  type)

Get MOBIFileMeta tag structure by MOBIFiletype type.

Parameters
[in]typeMOBIFiletype type
Returns
MOBIExthMeta structure for given type, .type = T_UNKNOWN on failure
Examples
mobitool.c.

◆ mobi_get_fileversion()

MOBI_EXPORT size_t mobi_get_fileversion ( const MOBIData m)

Get mobi file version.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
MOBI document version, 1 if ancient version (no MOBI header) or MOBI_NOTSET if error
Examples
common.c.

◆ mobi_get_first_resource_record()

MOBI_EXPORT size_t mobi_get_first_resource_record ( const MOBIData m)

Get sequential number of first resource record (image/font etc)

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
Record number or MOBI_NOTSET if not set
Examples
mobitool.c.

◆ mobi_get_flow_by_fid()

MOBI_EXPORT MOBIPart* mobi_get_flow_by_fid ( const MOBIRawml rawml,
const char *  fid 
)

Find flow part by flow id (fid) from kindle:flow:fid link. Flow fid is base32 encoded part uid.

Parameters
[in]rawmlStructure MOBIRawml
[in]fidString four character base32 fid
Returns
Pointer to MOBIPart structure, NULL on failure

◆ mobi_get_flow_by_uid()

MOBI_EXPORT MOBIPart* mobi_get_flow_by_uid ( const MOBIRawml rawml,
const size_t  uid 
)

Get rawml->flow MOBIPart part by uid.

Parameters
[in]rawmlMOBIRawml structure with loaded data
[in]uidUnique id
Returns
Pointer to MOBIPart structure, NULL on failure

◆ mobi_get_fullname()

MOBI_EXPORT MOBI_RET mobi_get_fullname ( const MOBIData m,
char *  fullname,
const size_t  len 
)

Get ebook full name stored in Record 0 at offset given in MOBI header.

Parameters
[in]mMOBIData structure with loaded data
[in,out]fullnameMemory area to be filled with zero terminated full name string
[in]lenMaximum length of the string without null terminator
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobitool.c.

◆ mobi_get_kf8boundary_seqnumber()

MOBI_EXPORT size_t mobi_get_kf8boundary_seqnumber ( const MOBIData m)

Get sequential number of KF8 Boundary record for KF7/KF8 hybrid file.

This function gets KF8 boundary offset from EXTH header

Parameters
[in]mMOBIData structure
Returns
KF8 Boundary record sequential number or MOBI_NOTSET if not found

◆ mobi_get_kf8offset()

MOBI_EXPORT size_t mobi_get_kf8offset ( const MOBIData m)

Get offset of KF8 Boundary for KF7/KF8 hybrid file cached in MOBIData structure.

Parameters
[in]mMOBIData structure
Returns
KF8 Boundary sequential number or zero if not found

◆ mobi_get_locale_number()

MOBI_EXPORT size_t mobi_get_locale_number ( const char *  locale_string)

Get Mobipocket locale number for a given string tag.

Locale strings are based on IANA language-subtag registry with some custom Mobipocket modifications. See mobi_locale array.

Parameters
[in]locale_stringLocale string tag
Returns
Mobipocket locale number

◆ mobi_get_locale_string()

MOBI_EXPORT const char* mobi_get_locale_string ( const uint32_t  locale_number)

Get pointer to locale tag for a given Mobipocket locale number.

Locale strings are based on IANA language-subtag registry with some custom Mobipocket modifications. See mobi_locale array.

Parameters
[in]locale_numberMobipocket locale number (as stored in MOBI header)
Returns
Pointer to locale string in mobi_locale array or NULL on error
Examples
common.c, and mobitool.c.

◆ mobi_get_orth_entry_length()

MOBI_EXPORT uint32_t mobi_get_orth_entry_length ( const MOBIIndexEntry entry)

Get text length for the orth entry.

Parameters
[in]entryMOBIIndexEntry structure
Returns
Text length, MOBI_NOTSET on failure

◆ mobi_get_orth_entry_offset()

MOBI_EXPORT uint32_t mobi_get_orth_entry_offset ( const MOBIIndexEntry entry)

Get entry start offset for the orth entry.

Parameters
[in]entryMOBIIndexEntry structure
Returns
Start offset, MOBI_NOTSET on failure

◆ mobi_get_part_by_uid()

MOBI_EXPORT MOBIPart* mobi_get_part_by_uid ( const MOBIRawml rawml,
const size_t  uid 
)

Get rawml->markup MOBIPart part by uid.

Parameters
[in]rawmlMOBIRawml structure with loaded data
[in]uidUnique id
Returns
Pointer to MOBIPart structure, NULL on failure

◆ mobi_get_rawml()

MOBI_EXPORT MOBI_RET mobi_get_rawml ( const MOBIData m,
char *  text,
size_t *  len 
)

Decompress text to a text buffer.

Parameters
[in]mMOBIData structure loaded with MOBI data
[in,out]textMemory area to be filled with decompressed output
[in,out]lenLength of the memory allocated for the text string, on return will be set to decompressed text length
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_get_record_by_seqnumber()

MOBI_EXPORT MOBIPdbRecord* mobi_get_record_by_seqnumber ( const MOBIData m,
const size_t  num 
)

Get palm database record with given sequential number (first record has number 0)

Parameters
[in]mMOBIData structure with loaded data
[in]numSequential number
Returns
Pointer to MOBIPdbRecord record structure, NULL on failure
Examples
mobitool.c.

◆ mobi_get_record_by_uid()

MOBI_EXPORT MOBIPdbRecord* mobi_get_record_by_uid ( const MOBIData m,
const size_t  uid 
)

Get palm database record with given unique id.

Parameters
[in]mMOBIData structure with loaded data
[in]uidUnique id
Returns
Pointer to MOBIPdbRecord record structure, NULL on failure

◆ mobi_get_record_extrasize()

MOBI_EXPORT 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.

Parameters
[in]recordMOBIPdbRecord structure containing the record
[in]flagsFlags from MOBI header (extra_flags)
Returns
The size of trailing bytes, MOBI_NOTSET on failure

◆ mobi_get_record_mb_extrasize()

MOBI_EXPORT 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.

Parameters
[in]recordMOBIPdbRecord structure containing the record
[in]flagsFlags from MOBI header (extra_flags)
Returns
The size of trailing bytes, MOBI_NOTSET on failure

◆ mobi_get_resource_by_fid()

MOBI_EXPORT MOBIPart* mobi_get_resource_by_fid ( const MOBIRawml rawml,
const char *  fid 
)

Find resource by flow id (fid) from kindle:embed:fid link. Flow fid is base32 encoded part uid.

Parameters
[in]rawmlStructure MOBIRawml
[in]fidString four character base32 fid
Returns
Pointer to MOBIPart structure, NULL on failure

◆ mobi_get_resource_by_uid()

MOBI_EXPORT MOBIPart* mobi_get_resource_by_uid ( const MOBIRawml rawml,
const size_t  uid 
)

Get MOBIPart resource record with given unique id.

Parameters
[in]rawmlMOBIRawml structure with loaded data
[in]uidUnique id
Returns
Pointer to MOBIPart resource structure, NULL on failure

◆ mobi_get_text_maxsize()

MOBI_EXPORT size_t mobi_get_text_maxsize ( const MOBIData m)

Get maximal size of all uncompressed text records.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
Size of text or MOBI_NOTSET if error

◆ mobi_get_textrecord_maxsize()

MOBI_EXPORT uint16_t mobi_get_textrecord_maxsize ( const MOBIData m)

Get maximal size of uncompressed text record.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
Size of text or MOBI_NOTSET if error

◆ mobi_init()

MOBI_EXPORT MOBIData* mobi_init ( void  )

Initializer for MOBIData structure.

It allocates memory for structure. Memory should be freed with mobi_free().

Returns
MOBIData on success, NULL otherwise

◆ mobi_init_rawml()

MOBI_EXPORT MOBIRawml* mobi_init_rawml ( const MOBIData m)

Initialize and return MOBIRawml structure.

MOBIRawml structure holds parsed text record metadata. It is used in the process of parsing rawml text data. It must be freed with mobi_free_rawml().

Parameters
[in]mInitialized MOBIData structure
Returns
MOBIRawml on success, NULL otherwise

◆ mobi_is_dictionary()

MOBI_EXPORT bool mobi_is_dictionary ( const MOBIData m)

Check if loaded document is dictionary.

Parameters
[in]mMOBIData structure with loaded mobi header
Returns
true or false
Examples
common.c.

◆ mobi_is_encrypted()

MOBI_EXPORT bool mobi_is_encrypted ( const MOBIData m)

Check if loaded document is encrypted.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
true or false
Examples
common.c.

◆ mobi_is_hybrid()

MOBI_EXPORT bool mobi_is_hybrid ( const MOBIData m)

Check if loaded MOBI data is KF7/KF8 hybrid file.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
true or false
Examples
common.c, and mobitool.c.

◆ mobi_is_kf8()

MOBI_EXPORT bool mobi_is_kf8 ( const MOBIData m)

Is file version 8 or above.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
True if file version is 8 or greater

◆ mobi_is_mobipocket()

MOBI_EXPORT bool mobi_is_mobipocket ( const MOBIData m)

Check if loaded document is MOBI/BOOK Mobipocket format.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
true or false

◆ mobi_is_rawml_kf8()

MOBI_EXPORT bool mobi_is_rawml_kf8 ( const MOBIRawml rawml)

Is file version 8 or above.

Parameters
[in]rawmlMOBIRawml structure with parsed document
Returns
True if file version is 8 or greater

◆ mobi_is_replica()

MOBI_EXPORT bool mobi_is_replica ( const MOBIData m)

Check if loaded document is Print Replica type.

Parameters
[in]mMOBIData structure with loaded Record(s) 0 headers
Returns
true or false
Examples
common.c, and mobitool.c.

◆ mobi_load_file()

MOBI_EXPORT MOBI_RET mobi_load_file ( MOBIData m,
FILE *  file 
)

Read MOBI document from file into MOBIData structure.

Parameters
[in,out]mMOBIData structure to be filled with read data
[in]fileFile descriptor to read from
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobimeta.c, and mobitool.c.

◆ mobi_load_filename()

MOBI_EXPORT MOBI_RET mobi_load_filename ( MOBIData m,
const char *  path 
)

Read MOBI document from a path into MOBIData structure.

Parameters
[in,out]mMOBIData structure to be filled with read data
[in]pathPath to a MOBI document on disk (eg. /home/me/test.mobi)
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_meta_add_asin()

MOBI_EXPORT MOBI_RET mobi_meta_add_asin ( MOBIData m,
const char *  asin 
)

Add document asin metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]asinString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_author()

MOBI_EXPORT MOBI_RET mobi_meta_add_author ( MOBIData m,
const char *  author 
)

Add document author metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]authorString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_contributor()

MOBI_EXPORT MOBI_RET mobi_meta_add_contributor ( MOBIData m,
const char *  contributor 
)

Add document contributor metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]contributorString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_copyright()

MOBI_EXPORT MOBI_RET mobi_meta_add_copyright ( MOBIData m,
const char *  copyright 
)

Add document copyright metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]copyrightString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_description()

MOBI_EXPORT MOBI_RET mobi_meta_add_description ( MOBIData m,
const char *  description 
)

Add document description metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]descriptionString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_imprint()

MOBI_EXPORT MOBI_RET mobi_meta_add_imprint ( MOBIData m,
const char *  imprint 
)

Add document imprint metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]imprintString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_isbn()

MOBI_EXPORT MOBI_RET mobi_meta_add_isbn ( MOBIData m,
const char *  isbn 
)

Add document isbn metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]isbnString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_language()

MOBI_EXPORT MOBI_RET mobi_meta_add_language ( MOBIData m,
const char *  language 
)

Add document language code metadata.

Locale strings are based on IANA language-subtag registry with some custom Mobipocket modifications. See mobi_locale array.

Parameters
[in,out]mMOBIData structure with loaded data
[in]languageString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_publishdate()

MOBI_EXPORT MOBI_RET mobi_meta_add_publishdate ( MOBIData m,
const char *  publishdate 
)

Add document publishdate metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]publishdateString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_publisher()

MOBI_EXPORT MOBI_RET mobi_meta_add_publisher ( MOBIData m,
const char *  publisher 
)

Add document publisher metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]publisherString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_review()

MOBI_EXPORT MOBI_RET mobi_meta_add_review ( MOBIData m,
const char *  review 
)

Add document review metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]reviewString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_subject()

MOBI_EXPORT MOBI_RET mobi_meta_add_subject ( MOBIData m,
const char *  subject 
)

Add document subject metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]subjectString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_add_title()

MOBI_EXPORT MOBI_RET mobi_meta_add_title ( MOBIData m,
const char *  title 
)

Add document title metadata.

Parameters
[in,out]mMOBIData structure with loaded data
[in]titleString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_asin()

MOBI_EXPORT MOBI_RET mobi_meta_delete_asin ( MOBIData m)

Delete all asin metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_author()

MOBI_EXPORT MOBI_RET mobi_meta_delete_author ( MOBIData m)

Delete all author metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_contributor()

MOBI_EXPORT MOBI_RET mobi_meta_delete_contributor ( MOBIData m)

Delete all contributor metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_copyright()

MOBI_EXPORT MOBI_RET mobi_meta_delete_copyright ( MOBIData m)

Delete all copyright metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_description()

MOBI_EXPORT MOBI_RET mobi_meta_delete_description ( MOBIData m)

Delete all description metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_imprint()

MOBI_EXPORT MOBI_RET mobi_meta_delete_imprint ( MOBIData m)

Delete all imprint metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_isbn()

MOBI_EXPORT MOBI_RET mobi_meta_delete_isbn ( MOBIData m)

Delete all isbn metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_language()

MOBI_EXPORT MOBI_RET mobi_meta_delete_language ( MOBIData m)

Delete all language code metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_publishdate()

MOBI_EXPORT MOBI_RET mobi_meta_delete_publishdate ( MOBIData m)

Delete all publishdate metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_publisher()

MOBI_EXPORT MOBI_RET mobi_meta_delete_publisher ( MOBIData m)

Delete all publisher metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_review()

MOBI_EXPORT MOBI_RET mobi_meta_delete_review ( MOBIData m)

Delete all review metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_subject()

MOBI_EXPORT MOBI_RET mobi_meta_delete_subject ( MOBIData m)

Delete all subject metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_delete_title()

MOBI_EXPORT MOBI_RET mobi_meta_delete_title ( MOBIData m)

Delete all title metadata.

Parameters
[in,out]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_asin()

MOBI_EXPORT char* mobi_meta_get_asin ( const MOBIData m)

Get document ASIN metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_author()

MOBI_EXPORT char* mobi_meta_get_author ( const MOBIData m)

Get document author metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_contributor()

MOBI_EXPORT char* mobi_meta_get_contributor ( const MOBIData m)

Get document contributor metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_copyright()

MOBI_EXPORT char* mobi_meta_get_copyright ( const MOBIData m)

Get document copyright metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_description()

MOBI_EXPORT char* mobi_meta_get_description ( const MOBIData m)

Get document description metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_imprint()

MOBI_EXPORT char* mobi_meta_get_imprint ( const MOBIData m)

Get document imprint metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_isbn()

MOBI_EXPORT char* mobi_meta_get_isbn ( const MOBIData m)

Get document ISBN metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_language()

MOBI_EXPORT char* mobi_meta_get_language ( const MOBIData m)

Get document language code metadata.

Locale strings are based on IANA language-subtag registry with some custom Mobipocket modifications. See mobi_locale array.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_publishdate()

MOBI_EXPORT char* mobi_meta_get_publishdate ( const MOBIData m)

Get document publishing date metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_publisher()

MOBI_EXPORT char* mobi_meta_get_publisher ( const MOBIData m)

Get document publisher metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_review()

MOBI_EXPORT char* mobi_meta_get_review ( const MOBIData m)

Get document review metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_subject()

MOBI_EXPORT char* mobi_meta_get_subject ( const MOBIData m)

Get document subject metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_get_title()

MOBI_EXPORT char* mobi_meta_get_title ( const MOBIData m)

Get document title metadata.

Returned string must be deallocated by caller

Parameters
[in]mMOBIData structure with loaded data
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_asin()

MOBI_EXPORT MOBI_RET mobi_meta_set_asin ( MOBIData m,
const char *  asin 
)

Set document asin metadata.

Replaces all asin metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]asinString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_author()

MOBI_EXPORT MOBI_RET mobi_meta_set_author ( MOBIData m,
const char *  author 
)

Set document author metadata.

Replaces all author metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]authorString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_contributor()

MOBI_EXPORT MOBI_RET mobi_meta_set_contributor ( MOBIData m,
const char *  contributor 
)

Set document contributor metadata.

Replaces all contributor metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]contributorString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_copyright()

MOBI_EXPORT MOBI_RET mobi_meta_set_copyright ( MOBIData m,
const char *  copyright 
)

Set document copyright metadata.

Replaces all copyright metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]copyrightString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_description()

MOBI_EXPORT MOBI_RET mobi_meta_set_description ( MOBIData m,
const char *  description 
)

Set document description metadata.

Replaces all description metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]descriptionString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_imprint()

MOBI_EXPORT MOBI_RET mobi_meta_set_imprint ( MOBIData m,
const char *  imprint 
)

Set document imprint metadata.

Replaces all imprint metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]imprintString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_isbn()

MOBI_EXPORT MOBI_RET mobi_meta_set_isbn ( MOBIData m,
const char *  isbn 
)

Set document isbn metadata.

Replaces all isbn metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]isbnString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_language()

MOBI_EXPORT MOBI_RET mobi_meta_set_language ( MOBIData m,
const char *  language 
)

Set document language code metadata.

Replaces all language metadata with new string Locale strings are based on IANA language-subtag registry with some custom Mobipocket modifications. See mobi_locale array.

Parameters
[in,out]mMOBIData structure with loaded data
[in]languageString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_publishdate()

MOBI_EXPORT MOBI_RET mobi_meta_set_publishdate ( MOBIData m,
const char *  publishdate 
)

Set document publishdate metadata.

Replaces all publishdate metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]publishdateString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_publisher()

MOBI_EXPORT MOBI_RET mobi_meta_set_publisher ( MOBIData m,
const char *  publisher 
)

Set document publisher metadata.

Replaces all publisher metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]publisherString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_review()

MOBI_EXPORT MOBI_RET mobi_meta_set_review ( MOBIData m,
const char *  review 
)

Set document review metadata.

Replaces all review metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]reviewString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_subject()

MOBI_EXPORT MOBI_RET mobi_meta_set_subject ( MOBIData m,
const char *  subject 
)

Set document subject metadata.

Replaces all subject metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]subjectString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_meta_set_title()

MOBI_EXPORT MOBI_RET mobi_meta_set_title ( MOBIData m,
const char *  title 
)

Set document title metadata.

Replaces all title metadata with new string

Parameters
[in,out]mMOBIData structure with loaded data
[in]titleString value
Returns
Pointer to null terminated string, NULL on failure

◆ mobi_next_exthrecord_by_tag()

MOBI_EXPORT MOBIExthHeader* mobi_next_exthrecord_by_tag ( const MOBIData m,
const MOBIExthTag  tag,
MOBIExthHeader **  start 
)

Get EXTH record with given MOBIExthTag tag. Start list search at given record.

If start_tag is NULL search will start from the root of the linked list. After successfull search start will be set to next record in the list.

Parameters
[in]mMOBIData structure with loaded data
[in]tagMOBIExthTag EXTH record tag
[in,out]startMOBIExthHeader EXTH record to begin search with
Returns
Pointer to MOBIExthHeader record structure

◆ mobi_parse_kf7()

MOBI_EXPORT MOBI_RET mobi_parse_kf7 ( MOBIData m)

Loader will parse KF7 part of hybrid file.

Parameters
[in,out]mMOBIData structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobitool.c.

◆ mobi_parse_kf8()

MOBI_EXPORT MOBI_RET mobi_parse_kf8 ( MOBIData m)

Loader will parse KF8 part of hybrid file.

This is the default option.

Parameters
[in,out]mMOBIData structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_parse_rawml()

MOBI_EXPORT MOBI_RET mobi_parse_rawml ( MOBIRawml rawml,
const MOBIData m 
)

Parse raw records into html flow parts, markup parts, resources and indices.

Parameters
[in,out]rawmlStructure rawml will be filled with reconstructed parts and resources
[in]mMOBIData structure
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobitool.c.

◆ mobi_parse_rawml_opt()

MOBI_EXPORT MOBI_RET mobi_parse_rawml_opt ( MOBIRawml rawml,
const MOBIData m,
bool  parse_toc,
bool  parse_dict,
bool  reconstruct 
)

Parse raw records into html flow parts, markup parts, resources and indices. Individual stages of the parsing may be turned on/off.

Parameters
[in,out]rawmlStructure rawml will be filled with reconstructed parts and resources
[in]mMOBIData structure
[in]parse_tocbool Parse content indices if true
[in]parse_dictbool Parse dictionary indices if true
[in]reconstructbool Recounstruct links, build opf, strip mobi-specific tags if true
Returns
MOBI_RET status code (on success MOBI_SUCCESS)

◆ mobi_pdbtime_to_time()

MOBI_EXPORT struct tm* mobi_pdbtime_to_time ( const long  pdb_time)

Convert time values from palmdoc header to time tm struct.

Older files set time in mac format. Newer ones in unix time.

Parameters
[in]pdb_timeTime value from PDB header
Returns
Time structure struct tm of time.h
Examples
mobitool.c.

◆ mobi_remove_hybrid_part()

MOBI_EXPORT MOBI_RET mobi_remove_hybrid_part ( MOBIData m,
const bool  remove_kf8 
)

Remove one version from hybrid file.

Hybrid file contains two document versions: KF8 version for devices that support new format and a version for older devices.

Parameters
[in,out]mMOBIData structure
[in]remove_kf8Remove new KF8 part if true, old part if false
Returns
MOBI_RET status code (on success MOBI_SUCCESS)
Examples
mobitool.c.

◆ mobi_version()

MOBI_EXPORT const char* mobi_version ( void  )

Get libmobi version.

Returns
String version
Examples
mobimeta.c, and mobitool.c.

◆ mobi_write_file()

MOBI_EXPORT MOBI_RET mobi_write_file ( FILE *  file,
MOBIData m 
)

Write mobi document to file.

Serializes metadata from MOBIData into raw records also stored in MOBIData (m->rec). Later writes palm database to file.

Parameters
[in,out]fileFile descriptor
[in,out]mMOBIData structure
Returns
MOBI_RET status code (MOBI_SUCCESS on success)
Examples
common.c, and mobimeta.c.