24typedef enum : uint32_t {
56 return report->write(report->ctx, bytes, len);
78 while (text[len] !=
'\0') {
102 const uint8_t
byte = (uint8_t)value;
130 }
while (value != 0U);
132 for (uint32_t i = count; (i < width) && (rc ==
k_ra8_ok); ++i) {
135 while ((count != 0U) && (rc ==
k_ra8_ok)) {
161 static const char s_digits[] =
"0123456789ABCDEF";
163 if (width > (uint32_t)
sizeof(text)) {
166 for (uint32_t i = 0U; i < width; ++i) {
170 return internal_put(report, (
const uint8_t*)text, width);
325 for (
size_t i = 0U; (i < count) && (rc ==
k_ra8_ok); ++i) {
326 const bool printable =
328 rc =
internal_char(report, (
char)(printable ? (
char)row[i] :
'.'));
364 while ((done < len) && (rc ==
k_ra8_ok)) {
365 size_t count = len - done;
366 if (count >
sizeof(row)) {
488 (info->
tile_w == info->
width) ?
"YES (tile_w == width)\n"
489 :
"NO (tile_w != width)\n");
564 internal_text(report,
" tile offset length payload tw th hash\n");
565 uint32_t shown = count;
569 for (uint32_t i = 0U; (i < shown) && (rc ==
k_ra8_ok); ++i) {
572 if ((shown < count) && (rc ==
k_ra8_ok)) {
575 if ((shown < count) && (rc ==
k_ra8_ok)) {
578 if ((shown < count) && (rc ==
k_ra8_ok)) {
589 if ((source ==
nullptr) || (source->
read_at ==
nullptr) || (workspace ==
nullptr) ||
590 (report ==
nullptr) || (report->write ==
nullptr)) {
595 .tile = workspace->
tile,
621 " duplicate hash candidates: ",
623 " (diagnostic only)\n");
626 const char* verdict =
"verdict: INVALID (see anomalies above)\n";
628 verdict =
"verdict: VALID (coverage exact, no duplicate tiles)\n";
630 verdict =
"verdict: VALID (coverage exact; duplicate hashes are diagnostic)\n";
634 return (rc ==
k_ra8_ok) ? audit_rc : rc;
@ k_jof_footer_bytes
Footer length.
@ k_jof_hdr_bytes
Header length.
@ k_jof_codec_deflate
Tile stream is one raw-DEFLATE run.
ra8_err_t jof_audit(jof_pread_fn pread, void *pread_ctx, uint64_t total_size, jof_audit_workspace_t *workspace, jof_audit_result_t *out)
Audit coverage, geometry and duplicate-content evidence in bounded RAM.
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_hex_dump_header(const ra8_fmt_sink_t *report, const char *label, uint64_t offset, size_t len)
Emit the label/length/offset header line for a hex/ASCII dump.
static ra8_err_t internal_table(const jof_audit_record_t *records, uint32_t count, const ra8_fmt_sink_t *report)
Emit the verbose per-tile table.
static ra8_err_t internal_value_line(const ra8_fmt_sink_t *report, const char *label, uint64_t value, const char *suffix)
Emit one label/value decimal line.
static ra8_err_t internal_dimensions(const jof_info_t *info, const ra8_fmt_sink_t *report)
Emit image, tile, and grid dimensions in the legacy CLI layout.
static ra8_err_t internal_hex_dump_row(const ra8_fmt_sink_t *report, uint64_t offset, const uint8_t *row, size_t count)
Render one already-loaded hex/ASCII row: offset, hex bytes, ASCII.
static ra8_err_t internal_hex_dump(const ra8_fmt_source_t *source, const ra8_fmt_sink_t *report, const char *label, uint64_t offset, size_t len)
Emit one labelled hex/ASCII source window.
static ra8_err_t internal_put(const ra8_fmt_sink_t *report, const uint8_t *bytes, size_t len)
Append a byte span to the report sink.
static ra8_err_t internal_hex(const ra8_fmt_sink_t *report, uint64_t value, uint32_t width)
Append an uppercase hexadecimal value with zero padding.
static ra8_err_t internal_u64(const ra8_fmt_sink_t *report, uint64_t value, uint32_t width)
Append an unsigned decimal with optional left padding.
static ra8_err_t internal_geometry(const ra8_fmt_source_t *source, const jof_info_t *info, const ra8_fmt_sink_t *report)
Emit parsed JOF geometry in the legacy CLI layout.
static ra8_err_t internal_read_exact(const ra8_fmt_source_t *source, uint64_t offset, uint8_t *bytes, size_t len)
Read an exact source window.
ra8_err_t ra8_fmt_jof_inspect_stream(const ra8_fmt_source_t *source, bool verbose, const ra8_fmt_jof_inspect_workspace_t *workspace, const ra8_fmt_sink_t *report)
Inspect one JOF source through callbacks and caller storage.
static ra8_err_t internal_table_row(const ra8_fmt_sink_t *report, uint32_t index, const jof_audit_record_t *record)
Render one audit-record row of the verbose per-tile table.
static ra8_err_t internal_char(const ra8_fmt_sink_t *report, char value)
Append one character.
fmt_text_const_t
Text formatting constants.
@ k_fmt_text_hex_digits
Maximum u64 hex digits.
@ k_fmt_text_nibble_mask
Low-nibble extraction mask.
@ k_fmt_text_dec_radix
Decimal formatting radix.
@ k_fmt_text_ascii_low
First printable ASCII byte.
@ k_fmt_text_col_width
Stored-value column width.
@ k_fmt_text_max_rows
Maximum verbose tile rows.
@ k_fmt_text_dec_digits
Maximum u64 decimal digits.
@ k_fmt_text_nibble
Bits in one hex digit.
@ k_fmt_text_ascii_high
Last printable ASCII byte.
@ k_fmt_text_hex_row
Bytes per hex dump row.
static ra8_err_t internal_text(const ra8_fmt_sink_t *report, const char *text)
Append a NUL-terminated literal to the report sink.
One decoded tile's stored window and content evidence.
uint16_t height
Edge-clamped decoded height.
uint32_t length
Stored-stream length.
uint16_t width
Edge-clamped decoded width.
uint32_t offset
Absolute stored-stream offset.
uint32_t content_hash
FNV-1a over decoded bytes.
uint32_t payload
Exact decoded payload bytes.
Geometry plus anomaly counts emitted by a complete audit.
jof_info_t info
Parsed atlas geometry.
uint32_t duplicate_candidates
Matching non-uniform hash/size evidence.
Caller-owned buffers consumed by one audit.
Parsed + validated geometry of one JOF atlas.
uint8_t bpp
Bytes per pixel (1, 3 or 4).
uint8_t codec
jof_codec_t member.
uint16_t tile_w
Tile width, pixels.
uint16_t width
Image width, pixels.
uint32_t index_off
Absolute byte offset of the tile index.
uint16_t tile_rows
Ceil(height / tile_h) tile rows.
uint16_t tile_h
Tile height, pixels.
uint32_t tile_count
Total tiles (== cols * rows).
uint16_t height
Image height, pixels.
uint32_t total_size
Whole atlas byte length (footer included).
uint16_t tile_cols
Ceil(width / tile_w) tile columns.
Exact caller-owned storage used by streaming JOF inspection.
uint32_t scratch_cap
Compressed staging capacity.
uint8_t * scratch
Compressed tile staging.
uint32_t tile_cap
Decoded tile capacity.
uint8_t * tile
Reusable decoded tile.
uint32_t record_cap
Record entries available.
jof_audit_record_t * records
Audit record array.
Injected append-only sink.
Immutable, randomly readable input object.
uint64_t size
Exact object byte length.
void * ctx
Backend-owned context.
jof_pread_fn read_at
Positioned-read callback.