ZEReader 0.1.0
A Zephyr-based E-Book-Reader
Loading...
Searching...
No Matches
epub.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2025 Anna-Lena Marx <mail@marx.engineer>
3 *
4 * SPDX-License-Identifier: MPL-2.0
5 */
6
7#ifndef _EPUB_H_
8#define _EPUB_H_
9
10#include <stdint.h>
11#include <stddef.h>
12
20
24#define EPUB_FILE_LEN_MAX 255
25
29#define EPUB_STATE_STRING_SIZE 500
30
34#define EPUB_CONTAINER_XML_READ_SIZE 350
35
39#define EPUB_OPF_READ_SIZE 800
40
46#define EPUB_LSDIR_CHARS_MAX 4096
47
51#define EPUB_PARSE_BUFFER_SIZE 4096 // Increased to accommodate larger raw content for parsing
52
59#define EPUB_MAX_PAGE_BUFFER_SIZE 1500 // A reasonable maximum for a display page
60
66#define STATE_FILE "/SD:/.statefile"
67
72typedef struct
73{
77 size_t number;
78
82 char *title;
83
87 char *author;
88
94
100
104typedef struct llist
105{
110
114 struct llist *next;
116
120typedef struct
121{
125 size_t number;
126
130 char *path;
132
136typedef struct dllist
137{
142
146 struct dllist *next;
147
151 struct dllist *prev;
153
157typedef struct
158{
162 uint16_t num_chapters;
163
168
173
178
183
188
193
198
203
208
212 struct
213 {
219 // May use title instead of number in future
220 char *title;
221
225 int32_t chapter;
226
230 int32_t page;
231
232 } state;
233
235
242
249
256
266
276
285
292
299
306
313
319void epub_update_page(int32_t update);
320
326int32_t epub_get_page(void);
327
335
342
349
351#endif
int32_t epub_get_page(void)
Get the current book's page within a chapter.
current_book_t * epub_get_current_book_state()
Restore the book state from a state file on the inserted SD card.
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.
book_entry_t * epub_get_book_entry_for_title(char *title)
Get the book_entry_t representation for a given book title.
int epub_restore_book()
Restore a book's reading state from a saved state file.
int epub_open_book(book_entry_t *book)
Load and open the EPUB represented by the given book_entry_t entry.
int epub_get_next_chapter()
Go to the next chapter.
void epub_update_page(int32_t update)
Update the current book's chapter page counter.
#define EPUB_MAX_PAGE_BUFFER_SIZE
The maximum configured page read size.
Definition epub.h:59
struct llist book_list_t
A linked list to store all book representations.
int epub_get_prev_chapter()
Go to the previous chapter.
int epub_free_current_book_resources()
Free all dynamically allocated resources within the current book.
book_list_t * epub_get_book_list()
Get the book list.
struct dllist chapter_list_t
A double-linked list to represent the chapters in a book.
const char * epub_get_current_chapter_content(void)
Get the full content of the current prettified chapter.
int epub_destroy_book_list()
Free all dynamically allocated resources within the book list.
int epub_write_current_book_state()
Save the current book's state in a state file on the inserted SD card.
int epub_initialize()
Initialize the SD card and fetch EPUBs, authors and titles.
Represents one EPUB E-Book.
Definition epub.h:73
char * entry_point
Definition epub.h:93
char * author
Definition epub.h:87
char * title
Definition epub.h:82
size_t number
Definition epub.h:77
char * content_dir
Definition epub.h:98
Represents one chapter in a book.
Definition epub.h:121
char * path
Definition epub.h:130
size_t number
Definition epub.h:125
Represents the current book read.
Definition epub.h:158
chapter_list_t * chapter_list
Definition epub.h:167
char * chapter_filename
Definition epub.h:182
uint16_t num_chapters
Definition epub.h:162
char * chapter_raw_content
Definition epub.h:187
char * title
Definition epub.h:220
chapter_list_t * current_chapter
Definition epub.h:172
size_t chapter_prettified_content_size
Definition epub.h:202
int32_t chapter
Definition epub.h:225
char * chapter_prettified_content
Definition epub.h:197
char * content_dir
Definition epub.h:207
size_t chapter_raw_content_size
Definition epub.h:192
char page[1500]
Definition epub.h:177
A double-linked list to represent the chapters in a book.
Definition epub.h:137
struct dllist * next
Definition epub.h:146
struct dllist * prev
Definition epub.h:151
chapter_entry_t * chapter
Definition epub.h:141
A linked list to store all book representations.
Definition epub.h:105
struct llist * next
Definition epub.h:114
book_entry_t * book
Definition epub.h:109