|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Private contracts for streamed EPUB XML consumers. More...
#include <stddef.h>#include <stdint.h>#include "epub_xml_shim_internal.h"#include "ra8_attributes.h"#include "xml.h"Go to the source code of this file.
Data Structures | |
| struct | priv_attr_t |
| Optional attribute span. More... | |
Functions | |
| void | priv_epub_xml_copy (const uint8_t *source, size_t source_len, xml_span_t span, char *destination, size_t capacity) |
| Copy decoded text into a bounded EPUB field. | |
| priv_attr_t | priv_epub_xml_attr (const uint8_t *source, size_t source_len, const xml_event_t *event, const char *name) |
| Find an exact-name attribute on one start event. | |
| bool | priv_epub_xml_attr_contains (const uint8_t *source, size_t source_len, priv_attr_t attribute, const char *needle) |
| Test whether a decoded attribute contains an ASCII literal. | |
| xml_span_t | priv_epub_xml_frame_name (const xml_reader_t *reader, uint16_t frame) |
| Return one live reader-frame name span. | |
| bool | priv_epub_xml_direct_child (uint16_t child, uint16_t parent) |
| Test whether a depth is exactly one level below another. | |
| bool | priv_epub_xml_ancestor_frame (uint16_t depth, uint16_t levels, uint16_t *out_frame) |
| Resolve a bounded ancestor frame index. | |
| uint16_t | priv_epub_xml_ancestor_marker (const xml_reader_t *reader, uint16_t depth, uint16_t levels) |
| Return a checked ancestor consumer marker. | |
| ra8_err_t | priv_epub_xml_reader (xml_reader_t *reader, const uint8_t *source, size_t length, epub_xml_workspace_t *workspace) |
| Initialise another validated EPUB pull pass. | |
| ra8_err_t | priv_epub_xml_find (const uint8_t *source, size_t length, epub_xml_workspace_t *workspace, const char *local, bool use_parent, uint32_t parent_offset, uint16_t parent_depth, xml_event_t *out) |
| Find the first local-name element under an optional direct parent. | |
Private contracts for streamed EPUB XML consumers.
Declares the helpers every consumer unit shares and their caller-owned workspace rules; definitions defer here so generated documentation has one authoritative block. Each unit's own file-local helpers are declared beside it, in epub_xml_opf_internal.h and epub_xml_toc_internal.h, so neither unit sees a static prototype it does not define. [Ring 4 / EPUB] {World: NS}
Definition in file epub_xml_consumer_internal.h.
| bool priv_epub_xml_ancestor_frame | ( | uint16_t | depth, |
| uint16_t | levels, | ||
| uint16_t * | out_frame ) |
Resolve a bounded ancestor frame index.
Subtracts one level at a time to avoid narrowing or underflow.
| [in] | depth | Current event depth. |
| [in] | levels | Ancestor distance. |
| [out] | out_frame | Resolved frame index. |
| false | levels exceeds depth. |
out_frame is writable. out_frame exactly. out_frame unchanged. Definition at line 98 of file epub_xml_shim.c.
Referenced by internal_ancestor_name(), internal_ncx_event(), and priv_epub_xml_ancestor_marker().
| uint16_t priv_epub_xml_ancestor_marker | ( | const xml_reader_t * | reader, |
| uint16_t | depth, | ||
| uint16_t | levels ) |
Return a checked ancestor consumer marker.
Converts an invalid ancestor request to zero.
| [in] | reader | Active reader. |
| [in] | depth | Current event depth. |
| [in] | levels | Ancestor distance. |
| 0 | Ancestor does not exist or carries no marker. |
depth. Definition at line 113 of file epub_xml_shim.c.
References xml_frame_t::consumer, xml_workspace_t::frames, priv_epub_xml_ancestor_frame(), and xml_reader_t::workspace.
Referenced by internal_metadata_text(), and internal_nav_event().
| priv_attr_t priv_epub_xml_attr | ( | const uint8_t * | source, |
| size_t | source_len, | ||
| const xml_event_t * | event, | ||
| const char * | name ) |
Find an exact-name attribute on one start event.
Traverses source order and returns an optional source-aliasing span.
| [in] | source | Immutable XML source. |
| [in] | source_len | Exact source extent. |
| [in] | event | Valid start event. |
| [in] | name | NUL-terminated exact QName. |
| present | Attribute matched. |
source_len. name remain readable for the call. Definition at line 45 of file epub_xml_shim.c.
References k_ra8_ok, xml_attribute_t::name, xml_attribute_t::value, xml_attr_begin(), xml_attr_next(), and xml_span_equal().
Referenced by internal_collect_spine(), internal_manifest_item(), internal_manifest_lookup(), internal_mark_metadata(), internal_nav_event_start(), internal_ncx_event(), internal_opf_first_event(), internal_opf_metadata_child(), internal_opf_shape(), internal_select_nav(), and priv_epub_xml_parse_container().
| bool priv_epub_xml_attr_contains | ( | const uint8_t * | source, |
| size_t | source_len, | ||
| priv_attr_t | attribute, | ||
| const char * | needle ) |
Test whether a decoded attribute contains an ASCII literal.
Decodes into the fixed EPUB path bound before substring search.
| [in] | source | Immutable XML source. |
| [in] | source_len | Exact source extent. |
| [in] | attribute | Optional encoded attribute. |
| [in] | needle | NUL-terminated search literal. |
needle. | false | Attribute is absent, oversized, invalid, or does not contain it. |
source_len. needle remains readable for the call. Definition at line 67 of file epub_xml_shim.c.
References k_epub_max_path_len, k_ra8_ok, priv_attr_t::present, priv_attr_t::span, strstr(), and xml_decode().
Referenced by internal_manifest_item(), and internal_select_nav().
| void priv_epub_xml_copy | ( | const uint8_t * | source, |
| size_t | source_len, | ||
| xml_span_t | span, | ||
| char * | destination, | ||
| size_t | capacity ) |
Copy decoded text into a bounded EPUB field.
Truncates only at a complete entity/codepoint, matching legacy fields.
| [in] | source | Immutable XML source. |
| [in] | source_len | Exact source extent. |
| [in] | span | Encoded source-relative span. |
| [out] | destination | Bounded NUL-terminated output. |
| [in] | capacity | Writable capacity including NUL. |
span lies within source_len validated bytes. Definition at line 35 of file epub_xml_shim.c.
References xml_decode_prefix().
Referenced by internal_manifest_item(), internal_metadata_text(), internal_nav_event(), internal_nav_event_start(), internal_ncx_event(), internal_opf_resolve_refs(), and priv_epub_xml_parse_container().
| bool priv_epub_xml_direct_child | ( | uint16_t | child, |
| uint16_t | parent ) |
Test whether a depth is exactly one level below another.
Guards UINT16_MAX before incrementing the parent depth.
| [in] | child | Candidate child depth. |
| [in] | parent | Candidate parent depth. |
| false | Parent is sentinel or depths are not adjacent. |
Definition at line 89 of file epub_xml_shim.c.
Referenced by internal_collect_spine(), internal_manifest_lookup(), internal_nav_event_start(), internal_nav_has_list(), internal_opf_first_event(), internal_opf_shape(), internal_toc_capacity(), and priv_epub_xml_find().
| ra8_err_t priv_epub_xml_find | ( | const uint8_t * | source, |
| size_t | length, | ||
| epub_xml_workspace_t * | workspace, | ||
| const char * | local, | ||
| bool | use_parent, | ||
| uint32_t | parent_offset, | ||
| uint16_t | parent_depth, | ||
| xml_event_t * | out ) |
Find the first local-name element under an optional direct parent.
Replays the validated source without retaining a DOM.
| [in] | source | Immutable XML source. |
| [in] | length | Exact source extent. |
| [in,out] | workspace | Exclusive reader scratch. |
| [in] | local | NUL-terminated local-name literal. |
| [in] | use_parent | Require the parent coordinates when true. |
| [in] | parent_offset | Parent start-markup offset. |
| [in] | parent_depth | Parent absolute depth. |
| [out] | out | Matching start event. |
| k_ra8_ok | Matching element found. |
| k_ra8_err_validation_failed | Match absent or replay failed. |
Definition at line 129 of file epub_xml_shim.c.
References k_ra8_err_validation_failed, k_ra8_ok, k_xml_event_end, k_xml_event_none, k_xml_event_start, priv_epub_xml_direct_child(), priv_epub_xml_reader(), xml_reader_next(), and xml_span_local_equal().
Referenced by priv_epub_xml_parse_container(), and priv_epub_xml_parse_ncx().
| xml_span_t priv_epub_xml_frame_name | ( | const xml_reader_t * | reader, |
| uint16_t | frame ) |
Return one live reader-frame name span.
Reconstructs the source-relative span retained for close validation.
| [in] | reader | Active reader. |
| [in] | frame | Live frame index. |
| span | Coordinates stored in the selected frame. |
reader and its workspace are valid. frame is below the live stack size. Definition at line 83 of file epub_xml_shim.c.
References xml_workspace_t::frames, xml_frame_t::name_length, xml_frame_t::name_offset, and xml_reader_t::workspace.
Referenced by internal_ancestor_depth(), internal_ancestor_name(), internal_collect_spine(), internal_manifest_lookup(), and internal_opf_first_event().
| ra8_err_t priv_epub_xml_reader | ( | xml_reader_t * | reader, |
| const uint8_t * | source, | ||
| size_t | length, | ||
| epub_xml_workspace_t * | workspace ) |
Initialise another validated EPUB pull pass.
Binds the shared reader stack within the caller-owned EPUB workspace.
| [out] | reader | Reader state to initialise. |
| [in] | source | Immutable complete XML source. |
| [in] | length | Exact source extent. |
| [in,out] | workspace | Exclusive EPUB XML scratch. |
| k_ra8_ok | Reader initialised. |
| k_ra8_err_invalid_size | Source extent is invalid. |
Definition at line 121 of file epub_xml_shim.c.
References epub_xml_workspace_t::reader, and xml_reader_init().
Referenced by internal_collect_spine(), internal_manifest_lookup(), internal_nav_has_list(), internal_opf_first(), internal_opf_shape(), internal_select_nav(), internal_toc_capacity(), priv_epub_xml_find(), priv_epub_xml_parse_nav(), and priv_epub_xml_parse_ncx().