34typedef enum : uint8_t {
39typedef enum : uint8_t {
115 if (ctx ==
nullptr) {
118 if (str ==
nullptr) {
126 const uint32_t len = (uint32_t)
strlen(str);
129 while (scan < ctx->string_size) {
131 const uint32_t cand_len = (uint32_t)
strlen(cand);
132 if (cand_len == len) {
133 uint32_t equal_bytes = 0U;
134 while ((equal_bytes < len) && (cand[equal_bytes] == str[equal_bytes])) {
137 if (equal_bytes == len) {
141 scan += cand_len + 1U;
145 const uint32_t need = len + 1U;
179 if (attr_count == 0U) {
184 for (uint16_t i = 0U; i < attr_count; i++) {
196 if (ctx ==
nullptr) {
202 if (attr_count != 0U) {
203 if (attrs ==
nullptr) {
235 if (ctx ==
nullptr) {
296 if (ctx ==
nullptr) {
343 uint8_t pixel_format,
367 uint8_t pixel_format,
371 if (ctx ==
nullptr) {
377 if (data_size != 0U) {
382 if (data ==
nullptr) {
397 if (data_size != 0U) {
418 uint8_t pixel_format,
420 uint32_t* out_data_off)
422 if (ctx ==
nullptr) {
425 if (out_data_off ==
nullptr) {
433 if (data_size != 0U) {
449 if (data_size != 0U) {
454 *out_data_off = data_off;
468 if (ctx ==
nullptr) {
490 uint32_t language_off,
491 uint32_t identifier_off,
492 uint32_t cover_image_index)
@ k_book_node_element
An element: has a tag name and attributes.
@ k_book_node_text
A text run: carries a string, no children.
@ k_book_nil
Absent index / "applies to all chapters".
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
size_t strlen(const char *s)
Calculate string length.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
#define ra8_log_error(tag, message)
RA8 log error.
ra8_rabook_pool_mode_t
Image-pool backing recorded by the builder context.
@ k_rabook_pool_external
Bytes live behind the read callback.
static const char *const s_tag_rabook
Component tag for finalizer diagnostics.
uint32_t ra8_rabook_add_element(ra8_rabook_ctx_t *ctx, uint32_t name_off, const book_attr_t *attrs, uint16_t attr_count)
Append an element node with its attributes; return its node index.
ra8_err_t ra8_rabook_link_sibling(ra8_rabook_ctx_t *ctx, uint32_t previous_node, uint32_t next_sibling)
Set previous_node's next sibling to next_sibling.
uint32_t ra8_rabook_add_text(ra8_rabook_ctx_t *ctx, uint32_t text_off)
Append a text node carrying text_off; return its node index.
ra8_err_t ra8_rabook_link_child(ra8_rabook_ctx_t *ctx, uint32_t parent, uint32_t child)
Set parent's first child to child.
uint32_t ra8_rabook_intern(ra8_rabook_ctx_t *ctx, const char *str)
Intern a NUL-terminated UTF-8 string into the pool, de-duplicated.
@ k_rabook_pool_internal
Bytes live in buf.image_pool.
@ k_rabook_pool_none
No non-empty image has selected storage.
uint32_t ra8_rabook_add_image(ra8_rabook_ctx_t *ctx, uint32_t id_off, uint16_t width, uint16_t height, uint8_t format, uint8_t pixel_format, const uint8_t *data, uint32_t data_size)
Append an image descriptor and copy its pixel/SVG bytes into the pool.
ra8_err_t ra8_rabook_set_metadata(ra8_rabook_ctx_t *ctx, uint32_t title_off, uint32_t author_off, uint32_t language_off, uint32_t identifier_off, uint32_t cover_image_index)
Record the book metadata offsets that land in the blob header.
uint32_t ra8_rabook_add_image_external(ra8_rabook_ctx_t *ctx, uint32_t id_off, uint16_t width, uint16_t height, uint8_t format, uint8_t pixel_format, uint32_t data_size, uint32_t *out_data_off)
Append an image descriptor whose bytes live in a caller-owned spool.
uint32_t ra8_rabook_add_stylesheet(ra8_rabook_ctx_t *ctx, uint32_t source_off, uint32_t scope_chapter)
Append a preserved stylesheet; return its stylesheet index.
static uint32_t internal_append_attrs(ra8_rabook_ctx_t *ctx, const book_attr_t *attrs, uint16_t attr_count)
Append attr_count attribute records to the attr table contiguously.
uint32_t ra8_rabook_add_chapter(ra8_rabook_ctx_t *ctx, uint32_t title_off, uint32_t href_off, uint32_t root_node)
Append a spine chapter; return its chapter index.
ra8_rabook_buffer_ptr_count_t
Number of caller-owned arena pointers validated by init.
@ k_rabook_buffer_ptr_count
chapters..out member pointers.
static ra8_err_t internal_check_buffer_members(const ra8_rabook_buffers_t *buf)
Reject a buffers struct with any NULL arena pointer.
static uint32_t internal_append_image_descriptor(ra8_rabook_ctx_t *ctx, uint32_t id_off, uint16_t width, uint16_t height, uint8_t format, uint8_t pixel_format, uint32_t data_off, uint32_t data_size)
Append one already-bounded image descriptor.
ra8_err_t rabook_compile_init(ra8_rabook_ctx_t *ctx, const ra8_rabook_buffers_t *buf)
Bind a builder context to its caller-provided arenas.
Zero-heap builder that emits a RABOOK1 blob (the #149 compiler back-end).
One name="value" attribute on an element.
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.
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).
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.
Caller-owned, fixed-capacity arenas the builder appends into (no heap).
uint32_t attr_cap
Max attribute records.
uint8_t * image_pool
Image-pool byte arena.
uint32_t chapter_cap
Max chapters.
uint32_t stylesheet_cap
Max stylesheets.
char * string_pool
String-pool byte arena.
uint32_t image_cap
Max image descriptors.
uint32_t image_pool_cap
Image-pool capacity in bytes.
book_image_t * images
Image-table arena.
uint32_t string_cap
String-pool capacity in bytes.
book_stylesheet_t * stylesheets
Stylesheet-table arena.
uint32_t node_cap
Max DOM nodes.
book_node_t * nodes
Node-table arena.
uint8_t * out
Final-blob output buffer.
book_attr_t * attrs
Attribute-table arena.
book_chapter_t * chapters
Chapter-table arena.
Builder state: the arenas plus running counts and a sticky-fail flag.
bool failed
Sticky: an arena overflowed.
uint32_t title_off
Metadata: title string offset.
uint8_t image_pool_mode
Internal builder storage mode.
uint32_t string_size
String-pool bytes used.
uint32_t stylesheet_count
Stylesheets appended so far.
uint32_t cover_image_index
Cover image index, or nil.
uint32_t image_pool_size
Image-pool bytes used.
ra8_rabook_buffers_t buf
Caller-provided arenas.
uint32_t language_off
Metadata: language string offset.
uint32_t chapter_count
Chapters appended so far.
uint32_t node_count
Nodes appended so far.
uint32_t image_count
Images appended so far.
uint32_t author_off
Metadata: author string offset.
uint32_t identifier_off
Metadata: identifier string offset.
uint32_t attr_count
Attributes appended so far.