24typedef enum : uint32_t {
93 }
while (value != 0U);
95 for (
size_t i = 0U; i < count; ++i) {
96 text[i] = reverse[count - i - 1U];
98 return sink->
write(sink->
ctx, (
const uint8_t*)text, count);
166 for (
int i = 2; i < argc; ++i) {
167 if ((
strcmp(argv[i],
"--format") == 0) && ((i + 1) < argc)) {
169 }
else if ((
strcmp(argv[i],
"--in") == 0) && ((i + 1) < argc)) {
170 args->
input = argv[++i];
171 }
else if ((
strcmp(argv[i],
"--out") == 0) && ((i + 1) < argc)) {
173 }
else if ((
strcmp(argv[i],
"--verbose") == 0) || (
strcmp(argv[i],
"-v") == 0)) {
175 }
else if ((argv[i][0] !=
'-') && (args->
input ==
nullptr)) {
176 args->
input = argv[i];
203 if (value > (SIZE_MAX - mask)) {
206 *out = (value + mask) & ~mask;
230 if (!
internal_align(offset, &aligned) || (bytes > (SIZE_MAX - aligned))) {
233 *next = aligned + bytes;
259 size_t producer_end = 0U;
264 size_t scratch_end = 0U;
265 size_t compare_end = 0U;
272 layout->
total = (producer_end > compare_end) ? producer_end : compare_end;
381 .work_cap = (uint32_t)layout->
producer,
384 .band_tile = root->
bytes,
449 const char* dump_name,
503 internal_status(errors,
"ra8_fmt: cannot create verify spool (rc=", rc);
510 if (args->
output !=
nullptr) {
560 size_t workspace_bytes,
584 if ((rc ==
k_ra8_ok) && (!sized || (layout->
total > workspace_bytes))) {
589 internal_status(report,
"verify: cannot read source dimensions (rc=", rc);
600 if ((handled ==
nullptr) || (workspace ==
nullptr)) {
604 if ((argc < 2) || (
strcmp(argv[1],
"verify") != 0)) {
622 sizeof(workspace->
bytes),
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_fail
Generic unspecified failure.
@ 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_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.
Raw file-descriptor adapters for the portable format-tool contracts.
ra8_err_t priv_fmt_host_transaction_begin(const char *path, ra8_fmt_host_transaction_t *state, ra8_fmt_transaction_t *out)
Begin a sibling-temp durable replacement transaction.
bool priv_fmt_host_sources_same(const ra8_fmt_host_source_t *first, const ra8_fmt_host_source_t *second)
Confirm two opens captured the same unchanged regular-file object.
ra8_err_t priv_fmt_host_source_open(const char *path, uint64_t max_size, ra8_fmt_host_source_t *out)
Open a bounded, regular, non-symlink input object.
ra8_fmt_sink_t priv_fmt_host_fd_sink(ra8_fmt_host_fd_sink_t *state)
Obtain the exact-write portable sink for a raw descriptor.
void priv_fmt_host_source_close(ra8_fmt_host_source_t *source)
Close an open host source; safe after failed open.
ra8_err_t priv_fmt_host_source_unchanged(const ra8_fmt_host_source_t *source)
Revalidate one open descriptor against its captured snapshot.
Anonymous raw-fd scratch artifacts for portable format verification.
void priv_fmt_host_spool_close(ra8_fmt_host_spool_t *state)
Close an anonymous scratch artifact.
ra8_err_t priv_fmt_host_spool_open(const char *anchor_path, ra8_fmt_host_spool_t *state, ra8_fmt_spool_t *out)
Create an anonymous scratch file beside an anchored input path.
static bool internal_align(size_t value, size_t *aligned)
Round one byte count up to the composition arena alignment.
Caller-workspace CLI composition for every supported tool verb.
static ra8_err_t internal_failed_append(void *ctx, const uint8_t *bytes, size_t len)
Append text or binary bytes to a bounded backend.
static void internal_cleanup(ra8_fmt_host_source_t *ref, ra8_fmt_host_source_t *got, ra8_fmt_host_spool_t *ref_spool, ra8_fmt_host_spool_t *got_spool)
Close all verifier-owned source and spool descriptors.
static void internal_bind(ra8_fmt_cli_workspace_t *root, const ra8_fmt_jof_verify_requirements_t *need, const verify_layout_t *layout, ra8_fmt_jof_verify_workspace_t *out)
Bind phase-overlaid producer and comparison arena views.
static bool internal_align(size_t value, size_t *out)
Align one size to the composition slice boundary.
static ra8_err_t internal_text(const ra8_fmt_sink_t *sink, const char *text)
Append one NUL-terminated text fragment.
static ra8_err_t internal_run(const ra8_fmt_host_source_t *ref, const ra8_fmt_host_source_t *got, const ra8_fmt_jof_verify_requirements_t *need, ra8_fmt_jof_verify_workspace_t *work, ra8_fmt_spool_t *ref_spool, ra8_fmt_spool_t *got_spool, ra8_fmt_transaction_t *dump, const char *dump_name, const ra8_fmt_sink_t *report)
Run the fully bound portable verifier engine.
static void internal_capacity(const ra8_fmt_sink_t *errors, const ra8_fmt_jof_verify_requirements_t *need, const verify_layout_t *layout, size_t supplied)
Report exact required and supplied shared-workspace evidence.
verify_cli_const_t
CLI and workspace-layout constants.
@ k_verify_cli_digits
Digits in uint64_t.
@ k_verify_cli_fail
Verification or host failure.
@ k_verify_cli_align
Arena slice alignment.
@ k_verify_cli_input
Maximum encoded input (256 MiB).
@ k_verify_cli_ok
Successful exact verdict.
@ k_verify_cli_decimal
Decimal formatting radix.
int priv_fmt_try_portable_verify(int argc, char **argv, ra8_fmt_cli_workspace_t *workspace, bool *handled)
Try the bounded two-spool JOF-verification command path.
static int internal_execute(const verify_cli_args_t *args, ra8_fmt_cli_workspace_t *workspace, ra8_fmt_host_source_t *ref_source, ra8_fmt_host_source_t *got_source, const ra8_fmt_jof_verify_requirements_t *need, const verify_layout_t *layout, const ra8_fmt_sink_t *errors, const ra8_fmt_sink_t *report)
Bind host spools and optional output, run, and close every owner.
static const ra8_fmt_transaction_ops_t s_failed_transaction_ops
static bool internal_add(size_t offset, size_t bytes, size_t *next)
Add one aligned arena slice without size_t wrapping.
static bool internal_layout(const ra8_fmt_jof_verify_requirements_t *need, verify_layout_t *layout)
Compute exact maximum high-water across producer and compare phases.
static void internal_failed_abort(void *ctx)
Abort an output transaction that never began.
static ra8_err_t internal_open_and_size(const verify_cli_args_t *args, size_t workspace_bytes, ra8_fmt_host_source_t *ref_source, ra8_fmt_host_source_t *got_source, ra8_fmt_jof_verify_requirements_t *need, verify_layout_t *layout, const ra8_fmt_sink_t *errors, const ra8_fmt_sink_t *report)
Open both verify sources and compute the workspace sizing.
static ra8_err_t internal_failed_commit(void *ctx)
Report commit failure for an unavailable optional output.
static void internal_field(const ra8_fmt_sink_t *sink, uint64_t value, const char *suffix, ra8_err_t *status)
Append one numeric field and suffix while status succeeds.
static void internal_status(const ra8_fmt_sink_t *sink, const char *prefix, ra8_err_t status)
Emit one canonical status diagnostic.
static ra8_err_t internal_u64(const ra8_fmt_sink_t *sink, uint64_t value)
Append one uint64_t in decimal.
static bool internal_parse(int argc, char **argv, verify_cli_args_t *args)
Parse only the legacy JOF verify option spellings.
Caller-workspace I/O contracts for portable format-tool engines.
ra8_err_t ra8_fmt_jof_verify_requirements(const ra8_fmt_source_t *source, ra8_fmt_jof_verify_requirements_t *out)
Derive exact producer and comparison storage for bounded JOF verification.
ra8_err_t ra8_fmt_jof_verify_stream(const ra8_fmt_source_t *reference_source, const ra8_fmt_source_t *banded_source, const ra8_fmt_jof_verify_requirements_t *requirements, ra8_fmt_jof_verify_workspace_t *workspace, ra8_fmt_spool_t *reference_spool, ra8_fmt_spool_t *banded_spool, ra8_fmt_transaction_t *dump, const char *dump_name, const ra8_fmt_sink_t *report)
Verify banded JOF pixels against an independently decoded row reference.
int strcmp(const char *s1, const char *s2)
Compare two null-terminated strings.
size_t strlen(const char *s)
Calculate string length.
static void internal_add(ra8_kbd_layout_t *kb, int32_t x, int32_t w, int32_t y, int32_t h, char lo, char hi, ra8_kbd_key_kind_t kind, uint8_t aux)
Append one key descriptor to the layout, bounded by k_ra8_kbd_max_keys.
One explicit, shared composition-root workspace for portable verbs.
uint8_t bytes[k_ra8_fmt_cli_workspace_bytes]
Shared named storage.
Append sink backed by a caller-owned descriptor.
Open raw-fd source and its portable view.
ra8_fmt_source_t source
Portable positioned-read view.
Caller-owned state for one unlinked scratch file.
Caller-owned state for one sibling-file transaction.
bool active
Transaction is usable.
Exact phase-reused storage requirements for JOF verification.
uint32_t row_bytes
One decoded reference row.
uint32_t reference_work_bytes
One-row reference producer arena.
uint32_t band_tile_bytes
Largest decoded subject tile.
uint32_t scratch_bytes
Largest stored-tile staging buffer.
uint32_t webp_work_bytes
Whole-frame WebP arena, or zero.
uint32_t banded_work_bytes
Banded subject producer arena.
Caller-owned phase-overlaid arenas for one bounded JOF verification.
Injected append-only sink.
ra8_fmt_sink_write_fn write
Exact append callback.
void * ctx
Backend-owned context.
Caller-owned scratch artifact with append, seal, and read seams.
Durable artifact-transaction operations.
void(* abort)(void *ctx)
Discard owned staging data.
One caller-owned artifact transaction.
void * ctx
Backend-owned state.
const ra8_fmt_transaction_ops_t * ops
Transaction implementation.
Parsed legacy-compatible JOF verify selections.
const char * output
Optional PPM path.
const char * format
Explicit format.
const char * input
Encoded source path.
Exact phase-overlaid byte offsets in the shared composition arena.
size_t webp
WebP arena offset.
size_t row
Reference-row offset.
size_t scratch
Comparison scratch offset.
size_t producer
Maximum producer work bytes.
size_t total
Exact maximum phase high-water.