|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Bounded XHTML-to-RABOOK streaming builder. More...
#include <stddef.h>#include <stdint.h>#include "book.h"#include "ra8_err.h"#include "rabook_compile.h"#include "xml.h"Go to the source code of this file.
Data Structures | |
| struct | ra8_rabook_xml_workspace_t |
| Caller-owned storage for one parser invocation. More... | |
Enumerations | |
| enum | ra8_rabook_xml_limits_t : uint16_t { k_ra8_rabook_xml_max_attributes = 32U , k_ra8_rabook_xml_body_siblings = 256U } |
| XHTML consumer limits matching the established format contract. More... | |
Functions | |
| ra8_err_t | ra8_rabook_xml_parse_chapter (const uint8_t *xhtml_bytes, size_t xhtml_len, ra8_rabook_ctx_t *ctx, const char *chapter_href, const char *chapter_title, ra8_rabook_xml_workspace_t *workspace) |
Parse one XHTML chapter and append it to ctx. | |
Bounded XHTML-to-RABOOK streaming builder.
Converts immutable XHTML into the canonical RABOOK DOM using a strict no-heap XML pull reader and explicit caller-owned workspace.
[Ring 4 / EPUB Compiler] {World: NS}
Definition in file ra8_rabook_xml_shim.h.
| enum ra8_rabook_xml_limits_t : uint16_t |
XHTML consumer limits matching the established format contract.
| Enumerator | |
|---|---|
| k_ra8_rabook_xml_max_attributes | Attributes accepted per element. |
| k_ra8_rabook_xml_body_siblings | Direct children searched for body. |
Definition at line 29 of file ra8_rabook_xml_shim.h.
|
nodiscard |
Parse one XHTML chapter and append it to ctx.
Validates all immutable source bytes before modifying ctx. A direct <body> child among at most 256 root element children is emitted. A document exceeding that bounded search is rejected; when the complete bounded set has no body, the document root is emitted. Text and attributes are entity-decoded; inter-element whitespace is preserved; comments, PIs, and CDATA are skipped.
| [in] | xhtml_bytes | Immutable complete XHTML byte sequence. |
| [in] | xhtml_len | Exact readable extent of xhtml_bytes in bytes. |
| [in,out] | ctx | Initialised builder receiving one chapter on success. |
| [in] | chapter_href | NUL-terminated immutable chapter identity. |
| [in] | chapter_title | NUL-terminated immutable chapter title. |
| [in,out] | workspace | Exclusive caller-owned parser and builder scratch. |
| k_ra8_ok | Chapter appended. |
| k_ra8_err_null_ptr | A required pointer is NULL. |
| k_ra8_err_invalid_size | xhtml_len is zero or exceeds UINT32_MAX. |
| k_ra8_err_validation_failed | XML is malformed, too deeply nested, or exceeds the bounded body search. |
| k_ra8_err_no_mem | Builder or attribute capacity is exhausted. |
ctx is initialized; its storage and workspace are writable, non-overlapping, and not used by another live operation. ctx to its entry state; bytes written beyond the restored active counts and all workspace bytes are unspecified scratch. Definition at line 608 of file ra8_rabook_xml_shim.c.
References ra8_rabook_ctx_t::failed, internal_emit(), internal_parse_chapter_validate_args(), internal_select(), k_book_nil, k_ra8_err_no_mem, k_ra8_err_validation_failed, k_ra8_ok, ra8_rabook_add_chapter(), ra8_rabook_intern(), ra8_rabook_xml_workspace_t::xml, and xml_validate().
Referenced by internal_compile_chapters().