94 if ((uint64_t)off != *cursor) {
97 const uint64_t end = *cursor + ((uint64_t)count * (uint64_t)elem);
98 if (end > (uint64_t)UINT32_MAX) {
123 static const char magic[8] = {
'R',
'A',
'B',
'O',
'O',
'K',
'1',
'\0'};
124 for (
size_t i = 0U; i <
sizeof(magic); ++i) {
125 if (ctx->
hdr.
magic[i] != magic[i]) {
136 const uint64_t node_mark_bytes =
222 uint8_t preceding = 0U;
225 if ((err ==
k_ra8_ok) && (preceding != 0U)) {
238 if ((err ==
k_ra8_ok) && (first == 0U)) {
258 if ((err ==
k_ra8_ok) && ((first != 0U) || (last != 0U))) {
@ 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.
@ k_book_format_version
Current .rabook layout revision.
@ k_book_flag_mask_known
Every bit this firmware understands; a set bit outside this mask fails book_validate().
Private wire geometry for strict RABOOK1 stream validation.
static uint32_t internal_book_stream_le32(const uint8_t *p)
Decode one little-endian 32-bit field from unaligned bytes.
@ k_stream_hdr_style_count
Stylesheet-table count field.
@ k_stream_hdr_chapter_count
Chapter-table count field.
@ k_stream_hdr_pool_off
Image-payload pool offset.
@ k_stream_hdr_node_count
DOM-node table count field.
@ k_stream_hdr_image_count
Image-table count field.
@ k_stream_hdr_string_size
Interned-string pool size.
@ k_stream_hdr_title
Title string-offset field.
@ k_stream_hdr_cover
Cover-image index field.
@ k_stream_hdr_attr_count
Attribute-table count field.
@ k_stream_hdr_total
Total-size field byte offset.
@ k_stream_hdr_string_off
Interned-string pool offset.
@ k_stream_hdr_version
Format-version field byte offset.
@ k_stream_hdr_identifier
Identifier string-offset field.
@ k_stream_hdr_crc
Body CRC-32 field byte offset.
@ k_stream_hdr_flags
Feature-flags field byte offset.
@ k_stream_hdr_image_off
Image-table byte offset.
@ k_stream_hdr_node_off
DOM-node table byte offset.
@ k_stream_hdr_author
Author string-offset field.
@ k_stream_hdr_style_off
Stylesheet-table byte offset.
@ k_stream_hdr_pool_size
Image-payload pool size.
@ k_stream_hdr_language
Language string-offset field.
@ k_stream_hdr_attr_off
Attribute-table byte offset.
@ k_stream_hdr_chapter_off
Chapter-table byte offset.
@ k_stream_bits_per_byte
Bits represented by one byte.
@ k_stream_mark_round
Ceiling-division numerator bias.
static ra8_err_t internal_validate_header_fields(const stream_validate_t *ctx)
Validate decoded header fields before walking the table layout.
ra8_err_t priv_book_stream_validate_string_envelope(const stream_validate_t *ctx)
Validate the string pool's leading and trailing NUL sentinels.
static void internal_decode_header(const uint8_t *raw, book_header_t *hdr)
Decode the fixed header from canonical little-endian wire bytes.
ra8_err_t priv_book_stream_nonempty_string_ref(const stream_validate_t *ctx, uint32_t off)
Require a string reference to name a non-empty interned string.
ra8_err_t priv_book_stream_read_validate_header(stream_validate_t *ctx)
Read, decode, and validate the canonical stream header and layout.
static ra8_err_t internal_layout_segment(uint32_t off, uint32_t count, uint32_t elem, uint64_t *cursor)
Require one segment to begin at the canonical cursor and advance it.
ra8_err_t priv_book_stream_read(const stream_validate_t *ctx, uint64_t off, uint8_t *dst, uint32_t len)
Read one exact, bounded source span.
ra8_err_t priv_book_stream_string_ref(const stream_validate_t *ctx, uint32_t off)
Require a referenced offset to name an interned-string boundary.
static ra8_err_t internal_validate_header_layout(const stream_validate_t *ctx)
Validate version, flags, exact source length, and canonical layout.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
Immutable validation state shared by the bounded table passes.
uint32_t scratch_cap
Transfer-buffer capacity.
void * read_ctx
Callback context.
book_header_t hdr
Decoded host-order header.
uint64_t source_size
Exact flat-source byte size.
book_stream_read_fn read
Exact source callback.