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
26#define EPUB_FILE_LEN_MAX 255
27
33#define EPUB_LSDIR_CHARS_MAX 4096
34
40#define EPUB_PAGE_SIZE 1400
41
47#define STATE_FILE "/SD:/.statefile"
48
53typedef struct
54{
58 size_t number;
59
63 char *title;
64
68 char *author;
69
75
79 char *root_dir;
81
85typedef struct llist
86{
91
95 struct llist *next;
97
101typedef struct
102{
106 size_t number;
107
111 char *path;
113
117typedef struct dllist
118{
123
127 struct dllist *next;
128
132 struct dllist *prev;
134
138typedef struct
139{
143 uint16_t num_chapters;
144
149
154
159
164
169
173 char *root_dir;
174
178 struct
179 {
185 // May use title instead of number in future
186 char *title;
187
188 // size_t book_number;
189
193 size_t chapter;
194
199 } state;
200
202
209
216
226
236
245
252
259
266
274
279
281#endif
char * epub_get_next_page()
Get the parsed and prettified next page.
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.
char * epub_get_prev_page()
Get the parsed and prettified previous page.
int epub_open_book(book_entry_t *book)
Load and open the EPUB represented by the given book_entry_t entry.
struct llist book_list_t
A linked list to store all book representations.
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.
int epub_write_current_book_state()
Save the current book's state in a state file on the inserted SD card.
#define EPUB_PAGE_SIZE
The configured page read size.
Definition epub.h:40
void epub_get_current_book_state()
Restore the book state from 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:54
char * entry_point
Definition epub.h:74
char * author
Definition epub.h:68
char * title
Definition epub.h:63
size_t number
Definition epub.h:58
char * root_dir
Definition epub.h:79
Represents one chapter in a book.
Definition epub.h:102
char * path
Definition epub.h:111
size_t number
Definition epub.h:106
Represents the current book read.
Definition epub.h:139
size_t file_offset
Definition epub.h:198
char * root_dir
Definition epub.h:173
char pretty_page[1400]
Definition epub.h:163
size_t chapter
Definition epub.h:193
chapter_list_t * chapter_list
Definition epub.h:148
char * chapter_filename
Definition epub.h:168
uint16_t num_chapters
Definition epub.h:143
char * title
Definition epub.h:186
chapter_list_t * current_chapter
Definition epub.h:153
char page[1400]
Definition epub.h:158
A double-linked list to represent the chapters in a book.
Definition epub.h:118
struct dllist * next
Definition epub.h:127
struct dllist * prev
Definition epub.h:132
chapter_entry_t * chapter
Definition epub.h:122
A linked list to store all book representations.
Definition epub.h:86
struct llist * next
Definition epub.h:95
book_entry_t * book
Definition epub.h:90