85typedef enum : uint32_t {
113typedef enum : uint8_t {
128typedef enum : uint32_t {
147typedef enum : uint32_t {
161typedef enum : uint8_t {
174typedef enum : uint8_t {
212typedef enum : uint8_t {
227typedef enum : uint16_t {
338 "book_stylesheet_t size pinned");
427static inline const void*
book_at(
const void* base, uint32_t off)
429 return (
const void*)&((
const uint8_t*)base)[off];
443static inline const char*
book_string(
const void* base, uint32_t off)
656 *
book_inflate_fn)(
const void* src,
size_t src_len,
void* dst,
size_t dst_cap,
size_t* out_len);
704 const void** out_base,
741 uint32_t chapter_idx,
778book_chapter_text(
const void* base, uint32_t chapter_idx,
char* out,
size_t cap,
size_t* out_len);
ra8_err_t book_chapter_text(const void *base, uint32_t chapter_idx, char *out, size_t cap, size_t *out_len)
Extract one chapter's readable plain text from the DOM.
static const book_image_t * book_images(const void *base)
Base of the image table.
book_struct_size_t
Pinned on-disk sizes of the blob's fixed-layout records.
@ k_book_sizeof_image
Bytes in book_image_t.
@ k_book_sizeof_header
Bytes in book_header_t.
@ k_book_sizeof_node
Bytes in book_node_t.
@ k_book_sizeof_chapter
Bytes in book_chapter_t.
@ k_book_sizeof_stylesheet
Bytes in book_stylesheet_t.
@ k_book_sizeof_attr
Bytes in book_attr_t.
static const void * book_at(const void *base, uint32_t off)
Resolve a blob-relative byte offset to a pointer.
book_node_kind_t
Discriminates the two kinds of DOM node.
@ k_book_node_element
An element: has a tag name and attributes.
@ k_book_node_text
A text run: carries a string, no children.
static const book_stylesheet_t * book_stylesheets(const void *base)
Base of the stylesheet table.
book_version_t
Wire-format version stamped into every blob header.
@ k_book_format_version
Current .rabook layout revision.
book_sentinel_t
Reserved index value meaning "no such element".
@ k_book_nil
Absent index / "applies to all chapters".
book_flag_t
Feature-flag bits carried in book_header_t.flags.
@ k_book_flag_rtl
Right-to-left reading order (manga): spine pages advance leaf-first, and the reader mirrors its page-...
@ k_book_flag_mask_known
Every bit this firmware understands; a set bit outside this mask fails book_validate().
static const book_chapter_t * book_chapters(const void *base)
Base of the chapter table.
ra8_err_t book_chapter_to_xhtml(const void *base, uint32_t chapter_idx, char *out, size_t cap, size_t *out_len)
Serialize one chapter's DOM subtree back to XHTML for the renderer.
static const char * book_node_name(const void *base, const book_node_t *node)
Tag name of an element node.
static const book_header_t * book_header(const void *base)
View the blob base as its header.
book_image_format_t
Pixel encoding of an entry in the image pool.
@ k_book_image_svg
Verbatim UTF-8 SVG source (vector; on-device rasterized).
@ k_book_image_gray4
4bpp gray, 2px/byte; pixel (x,y) is at flat index y*width + x.
static book_image_pixfmt_t book_image_pixfmt(const book_image_t *img)
Declared pixel depth of one image descriptor.
book_image_pixfmt_t
Pixel depth of a k_book_image_gray4 raster in the image pool.
@ k_book_pixfmt_gray4
4bpp packed grayscale, 2px/byte (default; every pre-field blob).
@ k_book_pixfmt_gray8
8bpp grayscale, 1px/byte (lossless against any grey panel).
static const book_node_t * book_nodes(const void *base)
Base of the DOM node table.
static const book_attr_t * book_attrs(const void *base)
Base of the attribute table.
static const char * book_string(const void *base, uint32_t off)
Resolve a string-pool offset to a NUL-terminated UTF-8 string.
static const char * book_node_text(const void *base, const book_node_t *node)
Text of a text node.
book_container_t
Constants of the on-disk .rabook chunked compression container.
@ k_book_container_header_len
Fixed header bytes ahead of the chunk table.
@ k_book_container_entry_len
One chunk-table entry (uint64 LE offset).
@ k_book_container_magic_len
Length of the "RBKC" magic.
static const uint8_t * book_image_data(const void *base, const book_image_t *img)
Image-pool pointer to one image's compressed pixel data.
ra8_err_t book_validate(const void *base, size_t size)
Validate that a byte buffer is a well-formed, intact .rabook blob.
ra8_err_t(* book_inflate_fn)(const void *src, size_t src_len, void *dst, size_t dst_cap, size_t *out_len)
Caller-supplied DEFLATE inflater used by book_open().
ra8_err_t book_open(const void *file, size_t file_len, book_inflate_fn inflate, void *scratch, size_t scratch_cap, const void **out_base, size_t *out_size)
Open a .rabook file: check the container, inflate, validate the blob.
static bool book_is_rtl(const void *base)
Whether the book declares right-to-left reading order (manga).
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
One name="value" attribute on an element.
uint32_t value_off
String-pool offset of the attribute value.
uint32_t name_off
String-pool offset of the attribute name.
One spine document (a renderable chapter) plus its TOC label.
uint32_t root_node
Node-table index of this chapter's root element.
uint32_t href_off
String-pool offset of the source spine href.
uint32_t title_off
String-pool offset of the TOC label ("" if none).
Descriptor for one transcoded image in the image pool.
uint16_t height
Pixel height.
uint32_t id_off
String-pool offset of the source href / manifest id.
uint32_t raw_size
Inflated length in bytes.
uint8_t format
book_image_format_t.
uint32_t data_size
Compressed length in bytes.
uint8_t pixel_format
book_image_pixfmt_t (0 == gray4; SVG: 0).
uint16_t width
Pixel width.
uint32_t data_off
Image-pool offset of the compressed pixel data.
uint16_t reserved2
Padding; 0.
uint8_t kind
book_node_kind_t.
uint32_t text_off
Text: string-pool offset of the run (element: 0).
uint16_t attr_count
Element: number of attributes (text: 0).
uint8_t reserved
Padding; 0.
uint32_t next_sibling
Index of next sibling node, or nil.
uint32_t name_off
Element: string-pool offset of tag name (text: 0).
uint32_t first_child
Index of first child node, or nil.
uint32_t first_attr
Index of first attribute, or nil.
A preserved CSS stylesheet and the chapter it scopes to.
uint32_t scope_chapter
Chapter index this applies to, or nil (= all).
uint32_t source_off
String-pool offset of the verbatim CSS text.