23typedef enum : uint32_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);
160 for (
int i = 2; i < argc; ++i) {
161 if ((
strcmp(argv[i],
"--format") == 0) && ((i + 1) < argc)) {
163 }
else if ((
strcmp(argv[i],
"--in") == 0) && ((i + 1) < argc)) {
164 args->
input = argv[++i];
165 }
else if ((
strcmp(argv[i],
"--out") == 0) && ((i + 1) < argc)) {
167 }
else if ((
strcmp(argv[i],
"--verbose") == 0) || (
strcmp(argv[i],
"-v") == 0)) {
169 }
else if ((argv[i][0] !=
'-') && (args->
input ==
nullptr)) {
170 args->
input = argv[i];
197 if (value > (SIZE_MAX - mask)) {
200 *aligned = (value + mask) & ~mask;
228 if ((
size_t)requirements->
webp_work_bytes > (SIZE_MAX - *webp_offset)) {
296 if ((rc ==
k_ra8_ok) && (!*sized || (*high_water > arena_cap))) {
297 internal_capacity(errors, requirements, *sized ? *high_water : SIZE_MAX, arena_cap);
339 .webp_work = (requirements->
webp_work_bytes == 0U) ?
nullptr : &arena[webp_offset],
372 if (sized && (high_water <= arena_cap)) {
385 if ((handled ==
nullptr) || (arena ==
nullptr)) {
389 if ((argc < 2) || (
strcmp(argv[1],
"convert") != 0)) {
400 if ((args.
input ==
nullptr) || (args.
output ==
nullptr)) {
401 (void)
internal_text(&errors,
"ra8_fmt: JOF convert needs --in and --out\n");
407 internal_status(&errors,
"ra8_fmt: cannot open convert input (rc=", rc);
411 size_t webp_offset = 0U;
412 size_t high_water = 0U;
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.
@ 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.
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 bool internal_high_water(const ra8_fmt_jof_convert_requirements_t *requirements, size_t *webp_offset, size_t *total)
Compute the exact shared-arena high-water for one conversion.
static void internal_report_run_failure(const ra8_fmt_sink_t *errors, ra8_err_t rc, bool sized, size_t high_water, size_t arena_cap)
Emit the one diagnostic matching how a failed conversion failed.
convert_cli_const_t
CLI status, input, and decimal formatting bounds.
@ k_convert_cli_input
Maximum source file (256 MiB).
@ k_convert_cli_decimal
Digits in uint64_t.
@ k_convert_cli_ok
Successful conversion.
@ k_convert_cli_align
Producer-arena slice alignment.
@ k_convert_cli_usage
Invalid command line.
@ k_convert_cli_fail
Command execution failed.
@ k_convert_cli_radix
Diagnostic number radix.
static void internal_status(const ra8_fmt_sink_t *errors, const char *prefix, ra8_err_t status)
Emit one canonical status diagnostic through fixed local formatting.
static ra8_err_t internal_text(const ra8_fmt_sink_t *sink, const char *text)
Append one NUL-terminated diagnostic fragment.
int priv_fmt_try_portable_convert(int argc, char **argv, uint8_t *arena, size_t arena_cap, bool *handled)
Try the caller-workspace JOF-convert command path.
static bool internal_parse(int argc, char **argv, convert_cli_args_t *args)
Parse the options accepted by the legacy convert command.
static ra8_err_t internal_size_input(const ra8_fmt_source_t *source, size_t arena_cap, const ra8_fmt_sink_t *errors, ra8_fmt_jof_convert_requirements_t *requirements, size_t *webp_offset, size_t *high_water, bool *sized)
Probe exact producer requirements and confirm the caller arena fits.
static ra8_err_t internal_run(const ra8_fmt_source_t *source, const char *output, const ra8_fmt_jof_convert_requirements_t *requirements, uint8_t *arena, size_t webp_offset, const ra8_fmt_sink_t *report)
Bind exact work slices and execute one already-open conversion.
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 remains successful.
static void internal_capacity(const ra8_fmt_sink_t *errors, const ra8_fmt_jof_convert_requirements_t *requirements, size_t required, size_t supplied)
Emit exact required/supplied workspace evidence.
static bool internal_align(size_t value, size_t *aligned)
Round one byte count up to the composition arena alignment.
static ra8_err_t internal_u64(const ra8_fmt_sink_t *sink, uint64_t value)
Append one unsigned decimal diagnostic field.
Caller-workspace CLI composition for every supported tool verb.
Caller-workspace I/O contracts for portable format-tool engines.
ra8_err_t ra8_fmt_jof_convert_requirements(const ra8_fmt_source_t *source, ra8_fmt_jof_convert_requirements_t *out)
Derive source geometry and exact JOF conversion workspace needs.
ra8_err_t ra8_fmt_jof_convert_stream(const ra8_fmt_source_t *source, const ra8_fmt_jof_convert_requirements_t *requirements, const ra8_fmt_jof_convert_workspace_t *workspace, ra8_fmt_transaction_t *transaction, const ra8_fmt_sink_t *report, const char *output_name)
Stream one encoded image into a durably published JOF artifact.
int strcmp(const char *s1, const char *s2)
Compare two null-terminated strings.
size_t strlen(const char *s)
Calculate string length.
Parsed arguments accepted by the portable convert composition.
const char * output
Destination JOF path.
const char * input
Source image path.
const char * format
Explicit format selector.
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 sibling-file transaction.
Source geometry and exact arenas required by one JOF conversion.
uint32_t webp_work_bytes
Exact WebP whole-frame bytes, or zero.
uint32_t work_bytes
Exact streaming-producer arena bytes.
Caller-owned arenas supplied to the streaming JOF converter.
Injected append-only sink.
ra8_fmt_sink_write_fn write
Exact append callback.
void * ctx
Backend-owned context.
Immutable, randomly readable input object.
One caller-owned artifact transaction.