ZEReader 0.1.0
A Zephyr-based E-Book-Reader
Loading...
Searching...
No Matches
EPUB management and parsing

Data Structures

struct  book_entry_t
 Represents one EPUB E-Book. More...
struct  llist
 A linked list to store all book representations. More...
struct  chapter_entry_t
 Represents one chapter in a book. More...
struct  dllist
 A double-linked list to represent the chapters in a book. More...
struct  current_book_t
 Represents the current book read. More...

Macros

#define EPUB_FILE_LEN_MAX   255
 The maximum file name length supported by the FatFS filesystem is 255.
#define EPUB_STATE_STRING_SIZE   500
 The maximum buffer size for the state string.
#define EPUB_CONTAINER_XML_READ_SIZE   350
 The read size for the container.xml file.
#define EPUB_OPF_READ_SIZE   800
 The read size for the content.opf file.
#define EPUB_LSDIR_CHARS_MAX   4096
 The maximum buffer size for listing directories.
#define EPUB_PARSE_BUFFER_SIZE   4096
 The maximum buffer size for parsing chapter files.
#define EPUB_MAX_PAGE_BUFFER_SIZE   1500
 The maximum configured page read size.
#define STATE_FILE   "/SD:/.statefile"
 The path and name for the reading state file.

Typedefs

typedef struct llist book_list_t
 A linked list to store all book representations.
typedef struct dllist chapter_list_t
 A double-linked list to represent the chapters in a book.

Functions

int epub_destroy_book_list ()
 Free all dynamically allocated resources within the book list.
int epub_initialize ()
 Initialize the SD card and fetch EPUBs, authors and titles.
book_list_tepub_get_book_list ()
 Get the book list.
book_entry_tepub_get_book_entry_for_num (uint16_t number)
 Get the book_entry_t representation for a given number in the book list.
book_entry_tepub_get_book_entry_for_title (char *title)
 Get the book_entry_t representation for a given book title.
int epub_open_book (book_entry_t *book)
 Load and open the EPUB represented by the given book_entry_t entry.
int epub_restore_book ()
 Restore a book's reading state from a saved state file.
const char * epub_get_current_chapter_content (void)
 Get the full content of the current prettified chapter.
int epub_get_next_chapter ()
 Go to the next chapter.
int epub_get_prev_chapter ()
 Go to the previous chapter.
void epub_update_page (int32_t update)
 Update the current book's chapter page counter.
int32_t epub_get_page (void)
 Get the current book's page within a chapter.
int epub_write_current_book_state ()
 Save the current book's state in a state file on the inserted SD card.
current_book_tepub_get_current_book_state ()
 Restore the book state from a state file on the inserted SD card.
int epub_free_current_book_resources ()
 Free all dynamically allocated resources within the current book.

Detailed Description

Macro Definition Documentation

◆ EPUB_LSDIR_CHARS_MAX

#define EPUB_LSDIR_CHARS_MAX   4096

The maximum buffer size for listing directories.

Needs a fixed size.

◆ EPUB_MAX_PAGE_BUFFER_SIZE

#define EPUB_MAX_PAGE_BUFFER_SIZE   1500

The maximum configured page read size.

This defines the maximum internal buffer size for a page. The UI will request a specific size, but it cannot exceed this internal buffer size.

◆ STATE_FILE

#define STATE_FILE   "/SD:/.statefile"

The path and name for the reading state file.

Currently a single global state is used.

Function Documentation

◆ epub_destroy_book_list()

int epub_destroy_book_list ( )

Free all dynamically allocated resources within the book list.

Return values
0on success.

◆ epub_free_current_book_resources()

int epub_free_current_book_resources ( )

Free all dynamically allocated resources within the current book.

Return values
0on success.

◆ epub_get_book_entry_for_num()

book_entry_t * epub_get_book_entry_for_num ( uint16_t number)

Get the book_entry_t representation for a given number in the book list.

Parameters
[in]numberThe number of the book within the book_list.
Return values
book_entry_tthe book_entry representation on success.
NULLif there is not book_entry for the given number.

◆ epub_get_book_entry_for_title()

book_entry_t * epub_get_book_entry_for_title ( char * title)

Get the book_entry_t representation for a given book title.

Parameters
[in]titleThe title of the book.
Return values
book_entry_tthe book_entry representation on success.
NULLif there is no book_entry for the given title.

◆ epub_get_book_list()

book_list_t * epub_get_book_list ( )

Get the book list.

Return values
book_list_ta linked list to store the books.

◆ epub_get_current_book_state()

current_book_t * epub_get_current_book_state ( )

Restore the book state from a state file on the inserted SD card.

Returns
A freshly allocated current book

◆ epub_get_current_chapter_content()

const char * epub_get_current_chapter_content ( void )

Get the full content of the current prettified chapter.

Returns
A pointer to the chapter content string. Returns NULL if no book/chapter is loaded.

◆ epub_get_next_chapter()

int epub_get_next_chapter ( )

Go to the next chapter.

Return values
0on success.

◆ epub_get_page()

int32_t epub_get_page ( void )

Get the current book's page within a chapter.

Return values
Apositive page number or 0 on success.

◆ epub_get_prev_chapter()

int epub_get_prev_chapter ( )

Go to the previous chapter.

Return values
0on success.

◆ epub_initialize()

int epub_initialize ( )

Initialize the SD card and fetch EPUBs, authors and titles.

Return values
0on success.

◆ epub_open_book()

int epub_open_book ( book_entry_t * book)

Load and open the EPUB represented by the given book_entry_t entry.

Parameters
[in]bookThe book's book_entry_t representation.
Return values
0on success.

◆ epub_restore_book()

int epub_restore_book ( )

Restore a book's reading state from a saved state file.

Return values
0on success.

◆ epub_update_page()

void epub_update_page ( int32_t update)

Update the current book's chapter page counter.

Parameters
[in]updateThe page difference, e.g. +1 or -1.

◆ epub_write_current_book_state()

int epub_write_current_book_state ( )

Save the current book's state in a state file on the inserted SD card.

Return values
>=0written bytes, on success.