ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mdl_cli_stream.c
Go to the documentation of this file.
1
9#include <stdint.h>
10
11#include "mdl_cli_internal.h"
12
14typedef enum : uint8_t {
17
19 const char* const* parts,
20 size_t count)
21{
22 if ((stream == nullptr) || (parts == nullptr)) {
23 return k_ra8_err_null_ptr;
24 }
25 if (count > k_mdl_cli_part_limit) {
27 }
29 for (size_t i = 0U; i < count; ++i) {
30 if (parts[i] == nullptr) {
31 return k_ra8_err_null_ptr;
32 }
33 const ra8_err_t err = ra8_io_stream_puts(stream, parts[i]);
34 if (err != k_ra8_ok) {
35 return err;
36 }
37 }
38 return k_ra8_ok;
39}
40
42 const char* const* parts,
43 size_t count)
44{
45 const ra8_err_t err = priv_mdl_cli_put_parts(stream, parts, count);
46 return (err == k_ra8_ok) ? k_ra8_err_invalid_arg : err;
47}
Private byte-stream helpers shared by mdl CLI units.
ra8_err_t priv_mdl_cli_put_parts(ra8_io_stream_t *stream, const char *const *parts, size_t count)
Write a bounded ordered vector of NUL-terminated text fragments.
mdl_cli_part_limit_t
Maximum fragments accepted by one CLI diagnostic operation.
@ k_mdl_cli_part_limit
Fixed bound for ordered text fragments.
ra8_err_t priv_mdl_cli_reject_parts(ra8_io_stream_t *stream, const char *const *parts, size_t count)
Write a rejection diagnostic and return invalid-argument status.
#define RA8_PRIV
Module-private helper: shared across TUs but only inside one library.
#define RA8_LOOP_BOUND(ceiling)
NASA Power-of-10 Rule 2: bind ONE loop to a compile-time ceiling.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
Definition ra8_err.h:478
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
Definition ra8_err.h:167
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
ra8_err_t ra8_io_stream_puts(ra8_io_stream_t *s, const char *str)
Write a NUL-terminated string (without the NUL) to the bound sink.
Caller-allocated byte-stream handle binding a sink to its context.