34 if ((abs_dot ==
nullptr) || (rel_dot ==
nullptr) || (extension[0] ==
'\0')) {
37 const int abs_length = snprintf(body->
actual_abs,
43 const int rel_length = snprintf(body->
actual_rel,
49 return (abs_length > 0) && ((size_t)abs_length <
sizeof(body->
actual_abs)) && (rel_length > 0) &&
50 ((size_t)rel_length <
sizeof(body->
actual_rel));
75 if ((copied < 0) || ((
size_t)copied >=
sizeof(body->
actual_abs))) {
79 char extension[8] = {};
139 if (body ==
nullptr) {
172 const uint32_t take = (length < room) ? length : room;
200 if ((body ==
nullptr) || (out_written ==
nullptr) || ((bytes ==
nullptr) && (length != 0U))) {
207 uint32_t offset = 0U;
212 *out_written = length;
228 *out_written = length;
235 const char* target_abs)
237 if ((body ==
nullptr) || (storage ==
nullptr) || (target_abs ==
nullptr) ||
238 (target_abs[0] !=
'/')) {
242 .target_abs = target_abs,
243 .target_rel =
nullptr,
250 const char* target_abs,
251 const char* target_rel)
253 if ((body ==
nullptr) || (storage ==
nullptr) || (target_abs ==
nullptr) ||
254 (target_rel ==
nullptr) || (target_abs[0] !=
'/')) {
258 .target_abs = target_abs,
259 .target_rel = target_rel,
272 if ((body ==
nullptr) || (body->
storage ==
nullptr)) {
294 if (body ==
nullptr) {
ra8_err_t priv_mdl_fetch_body_commit(mdl_fetch_body_t *body)
Validate exact size/hash and publish one prepared body.
ra8_err_t priv_mdl_fetch_body_init_exact(mdl_fetch_body_t *body, mdl_storage_t *storage, const char *target_abs)
Initialize an exact-path transactional body sink.
static ra8_err_t internal_body_write(void *context, const uint8_t *bytes, uint32_t length, uint32_t *out_written)
Consume one exact or magic-typed network body chunk.
mdl_net_body_sink_t priv_mdl_fetch_body_sink(mdl_fetch_body_t *body)
Return the network sink view of one body state.
static bool internal_body_paths(mdl_fetch_body_t *body, const char *extension)
Replace both requested suffixes with one verified image suffix.
ra8_err_t priv_mdl_fetch_body_prepare(mdl_fetch_body_t *body)
Finish prefix classification and make a nonempty stage commit-ready.
static ra8_err_t internal_body_flush_prefix(mdl_fetch_body_t *body)
Flush retained signature bytes into a newly active stage.
ra8_err_t priv_mdl_fetch_body_init_image(mdl_fetch_body_t *body, mdl_storage_t *storage, const char *target_abs, const char *target_rel)
Initialize a magic-typed image body sink.
static ra8_err_t internal_body_reset(void *context)
Abort a prior retry attempt without beginning a new one.
static ra8_err_t internal_body_begin(mdl_fetch_body_t *body)
Begin the exact or classified destination transaction once.
ra8_err_t priv_mdl_fetch_body_abort(mdl_fetch_body_t *body)
Abort any private stage owned by a body sink.
static uint32_t internal_body_buffer_prefix(mdl_fetch_body_t *body, const uint8_t *bytes, uint32_t length)
Retain the bounded image prefix and return consumed source bytes.
Portable single-transaction response-body sink for media fetches.
@ k_mdl_fetch_magic_bytes
Largest supported image signature prefix.
@ k_mdl_fetch_body_image
Derive the suffix from image magic.
@ k_mdl_fetch_body_exact
Publish under the supplied exact path.
ra8_err_t mdl_storage_txn_write(mdl_storage_txn_t *writer, const uint8_t *bytes, uint32_t length)
Append one complete caller chunk, tolerating bounded short writes.
ra8_err_t mdl_storage_txn_abort(mdl_storage_txn_t *writer)
Abort and clear one streamed transaction.
ra8_err_t mdl_storage_txn_commit(mdl_storage_txn_t *writer)
Independently validate and publish a completed streamed transaction.
ra8_err_t mdl_storage_txn_begin(mdl_storage_txn_t *writer, mdl_storage_t *storage, const char *destination)
Begin one streamed create or truthful atomic replacement.
Bounded URL naming and portable image-classification helpers.
bool mdl_urlname_sniff_image_type(const void *buf, size_t buf_len, const char *content_type, char *out_ext, size_t ext_cap, char *out_mime, size_t mime_cap)
Sniff true image extension and MIME type from magic bytes and/or HTTP Content-Type.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ 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.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
char * strrchr(const char *s, int c)
Locate last occurrence of character in string.
bool active
Begin succeeded.
Caller-owned state for one retryable streamed fetch.
mdl_storage_t * storage
Exclusive storage binding.
uint8_t prefix_bytes
Bytes retained in prefix.
const char * target_rel
Requested relative path or NULL.
mdl_storage_txn_t writer
Single private output stage.
uint64_t received
Network bytes accepted.
char actual_rel[k_mdl_relpath_max]
Magic-derived relative path.
mdl_fetch_body_mode_t mode
Exact or magic-typed publication.
uint8_t prefix[k_mdl_fetch_magic_bytes]
Deferred signature bytes.
char actual_abs[PATH_MAX]
Magic-derived final path.
const char * target_abs
Requested absolute destination.
Caller-owned lifecycle and write seam for one response body.
One non-reentrant downloader filesystem dependency bundle.
fw_fs_transaction_t transaction
Active private filesystem stage.