22typedef enum : uint32_t {
32typedef enum : uint8_t {
82 }
while (value != 0U);
84 for (
size_t i = 0U; i < count; ++i) {
85 text[i] = reverse[count - i - 1U];
87 return sink->
write(sink->
ctx, (
const uint8_t*)text, count);
138internal_parse(
int argc,
char** argv,
const char** input,
const char** format,
bool* verbose)
140 for (
int i = 2; i < argc; ++i) {
141 if ((
strcmp(argv[i],
"--verbose") == 0) || (
strcmp(argv[i],
"-v") == 0)) {
143 }
else if ((
strcmp(argv[i],
"--format") == 0) && ((i + 1) < argc)) {
145 }
else if ((
strcmp(argv[i],
"--in") == 0) && ((i + 1) < argc)) {
147 }
else if ((
strcmp(argv[i],
"--out") == 0) && ((i + 1) < argc)) {
149 }
else if ((argv[i][0] !=
'-') && (*input ==
nullptr)) {
179 if (explicit_name !=
nullptr) {
180 if (
strcmp(explicit_name,
"jof") == 0) {
182 }
else if (
strcmp(explicit_name,
"rabook") == 0) {
193 if ((got ==
sizeof(magic)) && (
memcmp(magic,
"JOF1",
sizeof(magic)) == 0)) {
195 }
else if ((got ==
sizeof(magic)) && (
memcmp(magic,
"RBKC",
sizeof(magic)) == 0)) {
281 .tile = &workspace->
bytes[records_bytes],
316 .table = (uint64_t*)workspace->
bytes,
318 .compressed = &workspace->
bytes[table_bytes],
355 const char* explicit_name,
390 if ((handled ==
nullptr) || (workspace ==
nullptr)) {
394 if ((argc < 2) || (
strcmp(argv[1],
"inspect") != 0)) {
397 const char* input =
nullptr;
398 const char* format =
nullptr;
399 bool verbose =
false;
404 (void)
internal_text(&errors,
"ra8_fmt: invalid inspect arguments\n");
408 if (input ==
nullptr) {
409 (void)
internal_text(&errors,
"ra8_fmt: no input file given\n");
412 return internal_open(input, format, verbose, workspace, handled, &errors);
ra8_err_t jof_audit_requirements(jof_pread_fn pread, void *pread_ctx, uint64_t total_size, jof_audit_requirements_t *out)
Parse an atlas and report exact caller-storage requirements.
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_ok
Success – operation completed with all postconditions satisfied.
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_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.
static void internal_workspace_error(const ra8_fmt_sink_t *sink, const jof_audit_requirements_t *need)
Report exact workspace requirements and capacities.
static int internal_open(const char *input, const char *explicit_name, bool verbose, ra8_fmt_cli_workspace_t *workspace, bool *handled, const ra8_fmt_sink_t *errors)
Open, classify, and inspect one bounded host source.
static ra8_err_t internal_format(const ra8_fmt_source_t *source, const char *explicit_name, cli_format_t *format)
Resolve an explicit name or four-byte container magic.
static int internal_run_rabook(const ra8_fmt_source_t *source, bool verbose, ra8_fmt_cli_workspace_t *workspace, const ra8_fmt_sink_t *output)
Bind the existing shared high-water to strict RBKC workspaces.
static ra8_err_t internal_text(const ra8_fmt_sink_t *sink, const char *text)
Append one literal through an injected sink.
cli_const_t
Exit values and explicit composition workspace budgets.
@ k_cli_decimal_chars
Maximum unsigned decimal digits.
@ k_cli_exit_fail
Command ran and failed.
@ k_cli_exit_ok
Successful command.
@ k_cli_input_cap
Maximum accepted input (256 MiB).
@ k_cli_decimal_radix
Status-code formatting radix.
@ k_cli_exit_usage
Invalid command line.
static bool internal_parse(int argc, char **argv, const char **input, const char **format, bool *verbose)
Parse the established inspect command arguments.
cli_format_t
Supported inspect-container classifications.
@ k_cli_format_none
Unknown or unsupported container.
@ k_cli_format_jof
JOF1 band-tile atlas.
@ k_cli_format_rabook
RBKC chunked RABOOK1 container.
static int internal_run_jof(const ra8_fmt_source_t *source, bool verbose, ra8_fmt_cli_workspace_t *workspace, const ra8_fmt_sink_t *output, const ra8_fmt_sink_t *errors)
Execute inspection after CLI ownership and source resolution.
static void internal_error_status(const ra8_fmt_sink_t *sink, const char *prefix, ra8_err_t status)
Emit one error line with an integer status.
static ra8_err_t internal_u64(const ra8_fmt_sink_t *sink, uint64_t value)
Append an unsigned decimal through an injected sink.
int priv_fmt_try_portable_inspect(int argc, char **argv, ra8_fmt_cli_workspace_t *workspace, bool *handled)
Try strict streamed JOF or RBKC inspection.
Caller-workspace CLI composition for every supported tool verb.
@ k_ra8_fmt_cli_record_cap
All legal JOF audit records.
@ k_ra8_fmt_cli_scratch_cap
Stored-tile bound bytes.
@ k_ra8_fmt_cli_rbkc_scratch_cap
Strict book work.
@ k_ra8_fmt_cli_rbkc_table_cap
At most 65,536 chunks plus end.
@ k_ra8_fmt_cli_rbkc_compressed_cap
One stored chunk.
@ k_ra8_fmt_cli_tile_cap
Decoded-tile bytes (4 MiB).
@ k_ra8_fmt_cli_rbkc_chunk_cap
One inflated chunk.
Caller-workspace I/O contracts for portable format-tool engines.
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.
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.
int strcmp(const char *s1, const char *s2)
Compare two null-terminated strings.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
size_t strlen(const char *s)
Calculate string length.
One decoded tile's stored window and content evidence.
Exact caller-storage requirements derived from a parsed atlas.
uint32_t scratch_bytes
Stored-stream scratch (zero for raw).
uint32_t record_count
Record entries required.
uint32_t tile_bytes
Decoded tile-buffer bytes required.
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.
Exact caller-owned storage used by streaming JOF inspection.
Caller-owned storage for strict streamed RBKC/RABOOK1 inspection.
Injected append-only sink.
ra8_fmt_sink_write_fn write
Exact append callback.
void * ctx
Backend-owned context.
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.