ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_viewer_output.c File Reference

Typed allocation-free diagnostic writers for the host viewer. More...

#include <stddef.h>
#include <stdint.h>
#include "ra8_attributes.h"
#include "ra8_err.h"
#include "ra8_io_stream.h"
#include "ra8_viewer_output_internal.h"
Include dependency graph for ra8_viewer_output.c:

Go to the source code of this file.

Functions

static ra8_err_t internal_put_text (ra8_io_stream_t *output, ra8_err_t current, const char *text)
 Append text only while an output sequence remains successful.
static ra8_err_t internal_put_u32 (ra8_io_stream_t *output, ra8_err_t current, uint32_t value)
 Append a decimal 32-bit value while a sequence remains successful.
static ra8_err_t internal_put_u64 (ra8_io_stream_t *output, ra8_err_t current, uint64_t value)
 Append a decimal 64-bit value while a sequence remains successful.
static ra8_err_t internal_put_hex (ra8_io_stream_t *output, ra8_err_t current, uint32_t value)
 Append an unpadded hexadecimal value while a sequence remains successful.
ra8_err_t priv_viewer_output_usage (ra8_io_stream_t *output, const char *executable)
 Write the complete command-line usage message.
ra8_err_t priv_viewer_output_capacity (ra8_io_stream_t *output, const char *subject, size_t required, size_t supplied)
 Write an exact workspace requirement diagnostic.
ra8_err_t priv_viewer_output_index_error (ra8_io_stream_t *output, const char *operation, uint32_t index, ra8_err_t error_code)
 Write a numbered operation failure and hexadecimal status.
ra8_err_t priv_viewer_output_error (ra8_io_stream_t *output, const char *operation, ra8_err_t error_code)
 Write an unnumbered operation failure and hexadecimal status.
ra8_err_t priv_viewer_output_open_error (ra8_io_stream_t *output, const char *path, ra8_err_t error_code)
 Write a document-open failure with its path and status.
ra8_err_t priv_viewer_output_opened (ra8_io_stream_t *output, const char *path, uint32_t page_count)
 Write a successful document-open diagnostic.
ra8_err_t priv_viewer_output_wrote (ra8_io_stream_t *output, const char *path)
 Write a successful path-publication diagnostic.
ra8_err_t priv_viewer_output_tile (ra8_io_stream_t *output, uint32_t tile, uint32_t width, uint32_t height, const char *path)
 Write a successful tile-publication diagnostic.
ra8_err_t priv_viewer_output_text (ra8_io_stream_t *output, const char *text)
 Write one fixed diagnostic without a terminating byte.

Detailed Description

Typed allocation-free diagnostic writers for the host viewer.

Composes the viewer's exact messages from bounded stream primitives, propagating the first short or failed write without varargs or hosted I/O.

Since
0.1.0

Definition in file ra8_viewer_output.c.

Function Documentation

◆ internal_put_hex()

ra8_err_t internal_put_hex ( ra8_io_stream_t * output,
ra8_err_t current,
uint32_t value )
static

Append an unpadded hexadecimal value while a sequence remains successful.

Preserves a preceding failure or delegates one bounded lowercase hexadecimal rendering to the portable stream facade.

Parameters
[in,out]outputBound byte stream.
[in]currentStatus from the preceding fragment.
[in]valueValue to append.
Returns
The first failure or the current fragment status.
Return values
k_ra8_okThe complete hexadecimal value was appended.
otherA preceding or current stream operation failed.
Precondition
output is bound.
current is a canonical stream status.
Postcondition
No fragment after a failure is attempted.
Success appends at least one lowercase hexadecimal digit.
Note
Not thread-safe for concurrent use of one stream.
Since
0.1.0

Definition at line 107 of file ra8_viewer_output.c.

References k_ra8_ok, and ra8_io_stream_put_hex().

Referenced by priv_viewer_output_error(), priv_viewer_output_index_error(), and priv_viewer_output_open_error().

◆ internal_put_text()

ra8_err_t internal_put_text ( ra8_io_stream_t * output,
ra8_err_t current,
const char * text )
static

Append text only while an output sequence remains successful.

Preserves a preceding failure without touching the destination; otherwise delegates the fragment to the portable stream facade.

Parameters
[in,out]outputBound byte stream.
[in]currentStatus from the preceding fragment.
[in]textNUL-terminated fragment.
Returns
The first failure or the current fragment status.
Return values
k_ra8_okThe fragment was appended completely.
otherA preceding or current stream operation failed.
Precondition
output is bound and text is NUL-terminated.
current is a canonical stream status.
Postcondition
No fragment after a failure is attempted.
Success appends the complete text without its NUL byte.
Note
Not thread-safe for concurrent use of one stream.
Since
0.1.0

Definition at line 37 of file ra8_viewer_output.c.

References k_ra8_ok, and ra8_io_stream_puts().

Referenced by priv_viewer_output_capacity(), priv_viewer_output_error(), priv_viewer_output_index_error(), priv_viewer_output_open_error(), priv_viewer_output_opened(), priv_viewer_output_tile(), priv_viewer_output_usage(), and priv_viewer_output_wrote().

◆ internal_put_u32()

ra8_err_t internal_put_u32 ( ra8_io_stream_t * output,
ra8_err_t current,
uint32_t value )
static

Append a decimal 32-bit value while a sequence remains successful.

Preserves a preceding failure or delegates one bounded decimal rendering to the portable stream facade.

Parameters
[in,out]outputBound byte stream.
[in]currentStatus from the preceding fragment.
[in]valueValue to append.
Returns
The first failure or the current fragment status.
Return values
k_ra8_okThe complete decimal value was appended.
otherA preceding or current stream operation failed.
Precondition
output is bound.
current is a canonical stream status.
Postcondition
No fragment after a failure is attempted.
Success appends the value without padding.
Note
Not thread-safe for concurrent use of one stream.
Since
0.1.0

Definition at line 60 of file ra8_viewer_output.c.

References k_ra8_ok, and ra8_io_stream_put_u32().

Referenced by priv_viewer_output_index_error(), priv_viewer_output_opened(), and priv_viewer_output_tile().

◆ internal_put_u64()

ra8_err_t internal_put_u64 ( ra8_io_stream_t * output,
ra8_err_t current,
uint64_t value )
static

Append a decimal 64-bit value while a sequence remains successful.

Preserves a preceding failure or delegates one bounded decimal rendering to the portable stream facade.

Parameters
[in,out]outputBound byte stream.
[in]currentStatus from the preceding fragment.
[in]valueValue to append.
Returns
The first failure or the current fragment status.
Return values
k_ra8_okThe complete decimal value was appended.
otherA preceding or current stream operation failed.
Precondition
output is bound.
current is a canonical stream status.
Postcondition
No fragment after a failure is attempted.
Success appends the value without padding.
Note
Not thread-safe for concurrent use of one stream.
Since
0.1.0

Definition at line 83 of file ra8_viewer_output.c.

References k_ra8_ok, and ra8_io_stream_put_u64().

Referenced by priv_viewer_output_capacity().

◆ priv_viewer_output_capacity()

ra8_err_t priv_viewer_output_capacity ( ra8_io_stream_t * output,
const char * subject,
size_t required,
size_t supplied )
nodiscard

Write an exact workspace requirement diagnostic.

Definition at line 125 of file ra8_viewer_output.c.

References internal_put_text(), internal_put_u64(), and ra8_io_stream_puts().

Referenced by internal_report_capacity().

◆ priv_viewer_output_error()

ra8_err_t priv_viewer_output_error ( ra8_io_stream_t * output,
const char * operation,
ra8_err_t error_code )
nodiscard

Write an unnumbered operation failure and hexadecimal status.

Definition at line 151 of file ra8_viewer_output.c.

References internal_put_hex(), internal_put_text(), and ra8_io_stream_puts().

Referenced by internal_dump_tile().

◆ priv_viewer_output_index_error()

ra8_err_t priv_viewer_output_index_error ( ra8_io_stream_t * output,
const char * operation,
uint32_t index,
ra8_err_t error_code )
nodiscard

Write a numbered operation failure and hexadecimal status.

Definition at line 138 of file ra8_viewer_output.c.

References internal_put_hex(), internal_put_text(), internal_put_u32(), and ra8_io_stream_puts().

Referenced by internal_dump_tile(), and internal_render_page().

◆ priv_viewer_output_open_error()

ra8_err_t priv_viewer_output_open_error ( ra8_io_stream_t * output,
const char * path,
ra8_err_t error_code )
nodiscard

Write a document-open failure with its path and status.

Definition at line 160 of file ra8_viewer_output.c.

References internal_put_hex(), internal_put_text(), and ra8_io_stream_puts().

Referenced by main().

◆ priv_viewer_output_opened()

ra8_err_t priv_viewer_output_opened ( ra8_io_stream_t * output,
const char * path,
uint32_t page_count )
nodiscard

Write a successful document-open diagnostic.

Definition at line 169 of file ra8_viewer_output.c.

References internal_put_text(), internal_put_u32(), and ra8_io_stream_puts().

Referenced by main().

◆ priv_viewer_output_text()

ra8_err_t priv_viewer_output_text ( ra8_io_stream_t * output,
const char * text )
nodiscard

Write one fixed diagnostic without a terminating byte.

Definition at line 202 of file ra8_viewer_output.c.

References ra8_io_stream_puts().

Referenced by internal_render_page(), and internal_run_window().

◆ priv_viewer_output_tile()

ra8_err_t priv_viewer_output_tile ( ra8_io_stream_t * output,
uint32_t tile,
uint32_t width,
uint32_t height,
const char * path )
nodiscard

Write a successful tile-publication diagnostic.

Definition at line 185 of file ra8_viewer_output.c.

References internal_put_text(), internal_put_u32(), and ra8_io_stream_puts().

Referenced by internal_dump_tile().

◆ priv_viewer_output_usage()

ra8_err_t priv_viewer_output_usage ( ra8_io_stream_t * output,
const char * executable )
nodiscard

Write the complete command-line usage message.

Definition at line 112 of file ra8_viewer_output.c.

References internal_put_text(), and ra8_io_stream_puts().

Referenced by internal_usage().

◆ priv_viewer_output_wrote()

ra8_err_t priv_viewer_output_wrote ( ra8_io_stream_t * output,
const char * path )
nodiscard

Write a successful path-publication diagnostic.

Definition at line 178 of file ra8_viewer_output.c.

References internal_put_text(), and ra8_io_stream_puts().

Referenced by internal_render_page().