21typedef enum : uint32_t {
52 return report->write(report->ctx, (
const uint8_t*)text,
strlen(text));
81 }
while (value != 0U);
82 while (width > count) {
89 for (uint32_t i = 0U; i < count; ++i) {
90 rendered[i] = reverse[count - i - 1U];
92 return report->write(report->ctx, (
const uint8_t*)rendered, count);
143 if ((adapter ==
nullptr) || (adapter->
source ==
nullptr) || ((bytes ==
nullptr) && (len != 0U))) {
147 if ((offset > source->
size) || ((uint64_t)len > (source->
size - offset))) {
151 while (done < (
size_t)len) {
153 const size_t ask = (size_t)len - done;
158 if ((got == 0U) || (got > ask)) {
186internal_inflate(
const void* src,
size_t src_len,
void* dst,
size_t dst_cap,
size_t* out_len)
188 if ((src ==
nullptr) || (dst ==
nullptr) || (out_len ==
nullptr)) {
191 const size_t result = tinfl_decompress_mem_to_mem(
196 (
int)(TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF));
197 if (result == TINFL_DECOMPRESS_MEM_TO_MEM_FAILED) {
311 for (uint32_t i = 0U; (i < rows) && (rc ==
k_ra8_ok); ++i) {
348 ?
internal_text(report,
"verdict: VALID (chunk table monotonic and complete)\n")
357 if ((source ==
nullptr) || (source->
read_at ==
nullptr) || (workspace ==
nullptr) ||
359 (workspace->
chunk ==
nullptr) || (workspace->
scratch ==
nullptr) || (report ==
nullptr) ||
360 (report->write ==
nullptr)) {
387 (void)
internal_text(report,
"verdict: INVALID (strict RBKC/RABOOK1 validation failed)\n");
Demand-paged chunk reader for the "RBKC" .rabook container.
ra8_err_t book_chunked_validate_strict(book_chunked_t *rd, uint8_t *chunk, uint32_t chunk_cap, uint8_t *scratch, uint32_t scratch_cap, book_header_t *out_header)
Strictly validate the complete flat blob behind an open RBKC reader.
ra8_err_t book_chunked_open(book_chunked_t *rd, ra8_vsource_read_fn file_read, void *file_ctx, uint64_t file_len, book_inflate_fn inflate, uint64_t *table_buf, uint32_t table_cap_entries, uint8_t *staging, uint32_t staging_cap)
Open a chunked .rabook container for demand-paged chunk reads.
static ra8_err_t internal_inflate(const void *source, size_t source_bytes, void *destination, size_t destination_capacity, size_t *output_bytes)
Inflate one zlib-wrapped RBKC chunk without heap allocation.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ 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.
Caller-workspace I/O contracts for portable format-tool engines.
static ra8_err_t internal_report(const ra8_fmt_sink_t *report, const ra8_fmt_source_t *source, const book_chunked_t *reader, bool verbose)
Emit a validated header, optional inventory, and stable verdict.
static ra8_err_t internal_inflate(const void *src, size_t src_len, void *dst, size_t dst_cap, size_t *out_len)
Inflate one RFC 1950 stream through miniz caller storage.
ra8_err_t ra8_fmt_rabook_inspect_stream(const ra8_fmt_source_t *source, bool verbose, ra8_fmt_rabook_inspect_workspace_t *workspace, const ra8_fmt_sink_t *report)
Strictly inspect one streamed RBKC container and its RABOOK1 payload.
static ra8_err_t internal_table(const ra8_fmt_sink_t *report, const book_chunked_t *reader, bool verbose)
Emit the bounded chunk inventory when verbose output is enabled.
static ra8_err_t internal_header(const ra8_fmt_sink_t *report, const ra8_fmt_source_t *source, const book_chunked_t *reader)
Emit the established RBKC header block.
static ra8_err_t internal_row(const ra8_fmt_sink_t *report, uint32_t idx, uint64_t begin, uint64_t end)
Emit one established-width chunk inventory row.
static ra8_err_t internal_u64(const ra8_fmt_sink_t *report, uint64_t value, uint32_t width)
Render one unsigned value with optional left padding.
static ra8_err_t internal_field(const ra8_fmt_sink_t *report, const char *label, uint64_t value)
Emit a labelled unsigned field and its terminating newline.
report_constant_t
Bounded report formatting constants.
@ k_report_digits
Digits required for uint64_t.
@ k_report_num_width
Legacy byte-column width.
@ k_report_idx_width
Legacy entry-column width.
@ k_report_rows
Maximum verbose inventory rows.
@ k_report_radix
Decimal digit radix.
static ra8_err_t internal_exact_read(void *opaque, uint64_t offset, uint8_t *bytes, uint32_t len)
Adapt legal short positioned reads to one exact book read.
static ra8_err_t internal_text(const ra8_fmt_sink_t *report, const char *text)
Append one NUL-terminated literal to the report sink.
size_t strlen(const char *s)
Calculate string length.
One open chunked .rabook file: parsed geometry + caller storage.
uint64_t inflated_total
Served flat-blob length.
const uint64_t * table
Chunk offsets.
uint32_t chunk_count
Chunk count.
uint32_t chunk_bytes
Inflated bytes per chunk.
uint64_t payload_off
First stream file offset.
Caller-owned storage for strict streamed RBKC/RABOOK1 inspection.
uint8_t * compressed
One compressed chunk.
uint32_t compressed_cap
Compressed chunk capacity.
uint64_t * table
Decoded RBKC offset entries.
uint32_t table_cap
Entries available at table.
uint8_t * scratch
Strict validator workspace.
uint8_t * chunk
One inflated chunk.
uint32_t chunk_cap
Inflated chunk capacity.
uint32_t scratch_cap
Validator workspace capacity.
Injected append-only sink.
Immutable, randomly readable input object.
uint64_t size
Exact object byte length.
void * ctx
Backend-owned context.
ra8_fmt_source_validate_fn validate
Optional stability callback.
jof_pread_fn read_at
Positioned-read callback.
Positioned-source binding for the exact book-reader callback.
const ra8_fmt_source_t * source
Borrowed immutable source.