GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Haoyi/libmobi: C library for handling Kindle (MOBI) formats of ebook documents

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

243 Commits
243 Commits

Folders and files

NameName
Last commit message
Last commit date
mobi.xcodeproj
mobi.xcodeproj
 
 
src
src
 
 
tests
tests
 
 
tools
tools
 
 
.travis.yml
.travis.yml
 
 
AUTHORS
AUTHORS
 
 
COPYING
COPYING
 
 
ChangeLog
ChangeLog
 
 
Makefile.am
Makefile.am
 
 
NEWS
NEWS
 
 
README.md
README.md
 
 
autogen.sh
autogen.sh
 
 
configure.ac
configure.ac
 
 
libmobi.pc.in
libmobi.pc.in
 
 
libmobi.vcxproj
libmobi.vcxproj
 
 

Repository files navigation

Libmobi

C library for handling Mobipocket/Kindle (MOBI) ebook format documents.

For examples on how to use the library have a look at tools folder.

Features:

  • reading and parsing:
    • some older text Palmdoc formats (pdb),
    • Mobipocket files (prc, mobi),
    • newer MOBI files including KF8 format (azw, azw3),
    • Replica Print files (azw4)
  • recreating source files using indices
  • reconstructing references (links and embedded) in html files
  • reconstructing source structure that can be fed back to kindlegen
  • reconstructing dictionary markup (orth, infl tags)
  • writing back loaded documents
  • metadata editing
  • handling encrypted documents

Todo:

  • improve writing
  • serialize rawml into raw records
  • process RESC records

Doxygen documentation:

  • functions,
  • structures for the raw, unparsed records metadata and data,
  • structures for the parsed records metadata and data,
  • enums

Source:

  • on github

Installation:

[for git] $ ./autogen.sh
$ ./configure
$ make
[optionally] $ make test
$ sudo make install

Optionally provided Xcode and MSVC++ project files

Usage

  • single include file: #include <mobi.h>
  • linker flag: -lmobi
  • basic usage:
#include <mobi.h>

/* Initialize main MOBIData structure */
/* Must be deallocated with mobi_free() when not needed */
MOBIData *m = mobi_init();
if (m == NULL) { 
  return ERROR; 
}

/* Open file for reading */
FILE *file = fopen(fullpath, "rb");
if (file == NULL) {
  mobi_free(m);
  return ERROR;
}

/* Load file into MOBIData structure */
/* This structure will hold raw data/metadata from mobi document */
MOBI_RET mobi_ret = mobi_load_file(m, file);
fclose(file);
if (mobi_ret != MOBI_SUCCESS) { 
  mobi_free(m);
  return ERROR;
}

/* Initialize MOBIRawml structure */
/* Must be deallocated with mobi_free_rawml() when not needed */
/* In the next step this structure will be filled with parsed data */
MOBIRawml *rawml = mobi_init_rawml(m);
if (rawml == NULL) {
  mobi_free(m);
  return ERROR;
}
/* Raw data from MOBIData will be converted to html, css, fonts, media resources */
/* Parsed data will be available in MOBIRawml structure */
mobi_ret = mobi_parse_rawml(rawml, m);
if (mobi_ret != MOBI_SUCCESS) {
  mobi_free(m);
  mobi_free_rawml(rawml);
  return ERROR;
}

/* Do something useful here */
/* ... */
/* For examples how to access data in MOBIRawml structure see mobitool.c */

/* Free MOBIRawml structure */
mobi_free_rawml(rawml);

/* Free MOBIData structure */
mobi_free(m);

return SUCCESS;
  • for examples of usage, see tools

Requirements

  • compiler supporting C99
  • zlib (optional, configure --with-zlib=no to use included miniz.c instead)
  • libxml2 (optional, configure --with-libxml2=no to use internal xmlwriter)
  • tested with gcc (>=4.2.4), clang (llvm >=3.4), sun c (>=5.13), MSVC++ (2015)
  • builds on Linux, MacOS X, Windows (MSVC++, MinGW), Android, Solaris
  • tested architectures: x86, x86-64, arm, ppc
  • works cross-compiled on Kindle :)

Tests

  • Travis status
  • Coverity status

Projects using libmobi

  • KyBook 2 Reader
  • @Voice Aloud Reader
  • QLMobi quicklook plugin
  • Librera Reader
  • ... (let me know to include your project)

License:

  • LGPL, either version 3, or any later

Credits:

  • The huffman decompression and KF8 parsing algorithms were learned by studying python source code of KindleUnpack.
  • Thanks to all contributors of Mobileread MOBI wiki

About

C library for handling Kindle (MOBI) formats of ebook documents

Resources

Readme
LGPL-3.0 license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.