libmobi
Version 0.12
C Library สำหรับการจัดการเอกสารรูปแบบ mobipocket/Kindle (MOBI)
ห้องสมุดมาพร้อมกับเครื่องมือบรรทัดคำสั่งหลายอย่างสำหรับการทำงานกับ mobi ebooks แหล่งที่มาของเครื่องมืออาจใช้เป็นตัวอย่างเกี่ยวกับวิธีการใช้ไลบรารี
[for git] $ ./autogen.sh
$ ./configure
$ make
[optionally] $ make test
$ sudo make install
บน MacOS คุณสามารถติดตั้งผ่าน Homebrew ด้วย brew install libmobi
#include <mobi.h>-lmobi #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 ;