stdio_stream adapter implementation.
More...
#include "internal/stdio_stream_handle.h"#include "internal/stdio_stream_ctor_ud.h"#include "stdio_stream/cr/stdio_stream_cr_api.h"#include "stream/adapters/stream_env.h"#include "osal/mem/osal_mem.h"#include "policy/lexleo_assert.h"
Go to the source code of this file.
Functions | |
| stdio_stream_cfg_t | stdio_stream_default_cfg (void) |
Return a default configuration for the stdio_stream adapter. | |
| stdio_stream_env_t | stdio_stream_default_env (const osal_stdio_ops_t *stdio_ops, const osal_mem_ops_t *mem, const stream_env_t *port_env) |
Build a default environment for the stdio_stream adapter. | |
| static size_t | stdio_stream_read (void *backend, void *buf, size_t n, stream_status_t *st) |
| static size_t | stdio_stream_write (void *backend, const void *buf, size_t n, stream_status_t *st) |
| static stream_status_t | stdio_stream_flush (void *backend) |
| static stream_status_t | stdio_stream_close (void *backend) |
| stream_status_t | stdio_stream_create_stream (stream_t **out, const stdio_stream_args_t *args, const stdio_stream_cfg_t *cfg, const stdio_stream_env_t *env) |
| Create a standard-I/O-backed stream instance. | |
| static void | stdio_stream_destroy_ud_ctor (const void *ud, const osal_mem_ops_t *mem) |
| stream_status_t | stdio_stream_create_desc (stream_adapter_desc_t *out, stream_key_t key, const stdio_stream_cfg_t *cfg, const stdio_stream_env_t *env, const osal_mem_ops_t *mem) |
Build a stream adapter descriptor for the stdio_stream adapter. | |
| stream_status_t | stdio_stream_ctor (const void *ud, const void *args, stream_t **out) |
Factory-compatible constructor callback for the stdio_stream adapter. | |
Variables | |
| static const stream_vtbl_t | STDIO_STREAM_VTBL |
This module implements the stdio_stream adapter, which exposes the process standard I/O streams (stdin, stdout, and stderr) through the generic stream port.
Definition in file stdio_stream.c.
|
static |
Definition at line 136 of file stdio_stream.c.
| stream_status_t stdio_stream_create_desc | ( | stream_adapter_desc_t * | out, |
| stream_key_t | key, | ||
| const stdio_stream_cfg_t * | cfg, | ||
| const stdio_stream_env_t * | env, | ||
| const osal_mem_ops_t * | mem | ||
| ) |
| out | Output location that receives the constructed adapter descriptor on success. |
| key | Borrowed adapter registration key. |
| cfg | Borrowed adapter configuration copied into descriptor-owned constructor data. |
| env | Borrowed adapter environment copied into descriptor-owned constructor data. |
| mem | Borrowed memory operations table used to allocate the descriptor-owned constructor data. |
| STREAM_STATUS_OK | The descriptor was created successfully. |
| STREAM_STATUS_INVALID | One or more arguments are invalid. |
| STREAM_STATUS_OOM | Memory allocation failed. |
The descriptor produced by this function is intended to be registered into a stream factory. The constructor user data allocated for that descriptor is owned by the descriptor lifecycle and must therefore use the factory memory operations.
Definition at line 245 of file stdio_stream.c.
| stream_status_t stdio_stream_create_stream | ( | stream_t ** | out, |
| const stdio_stream_args_t * | args, | ||
| const stdio_stream_cfg_t * | cfg, | ||
| const stdio_stream_env_t * | env | ||
| ) |
This function allocates and initializes a public stream_t whose backend wraps stdin, stdout, or stderr according to args->kind.
Ownership:
*out.stream_destroy().*out is left unchanged.| [out] | out | Receives the created stream handle. Must not be NULL. |
| [in] | args | Creation arguments selecting which standard I/O stream is wrapped by the created adapter instance. Must not be NULL. |
| [in] | cfg | Adapter configuration. Must not be NULL. |
| [in] | env | Adapter environment containing injected dependencies. Must not be NULL. |
| STREAM_STATUS_OK | Stream successfully created. |
| STREAM_STATUS_INVALID | One or more arguments are invalid. |
| STREAM_STATUS_OOM | Memory allocation failed. |
Definition at line 156 of file stdio_stream.c.
| stream_status_t stdio_stream_ctor | ( | const void * | ud, |
| const void * | args, | ||
| stream_t ** | out | ||
| ) |
| ud | Borrowed adapter-specific constructor user data. |
| args | Borrowed creation arguments expected by the adapter factory contract. |
| out | Output location that receives the created stream_t * on success. |
| STREAM_STATUS_OK | The stream was created successfully. |
| STREAM_STATUS_INVALID | One or more arguments are invalid. |
| STREAM_STATUS_OOM | Memory allocation failed. |
This callback is intended to be stored in a stream_adapter_desc_t and invoked through the stream factory contract.
Definition at line 289 of file stdio_stream.c.
| stdio_stream_cfg_t stdio_stream_default_cfg | ( | void | ) |
This helper provides a value-initialized baseline configuration that the Composition Root may override.
stdio_stream_cfg_t. Definition at line 27 of file stdio_stream.c.
| stdio_stream_env_t stdio_stream_default_env | ( | const osal_stdio_ops_t * | stdio_ops, |
| const osal_mem_ops_t * | mem, | ||
| const stream_env_t * | port_env | ||
| ) |
This helper packages borrowed dependencies into a value-initialized stdio_stream_env_t.
The returned environment does not take ownership of any pointer passed as argument.
| stdio_ops | Borrowed OSAL stdio operations table used by the adapter backend to access the standard streams and the stdio primitives required to implement the stream port contract. | |
| mem | Borrowed memory operations table used by the adapter backend. | |
| [in] | port_env | Borrowed stream port environment. |
stdio_stream_env_t aggregating the provided dependencies. Definition at line 31 of file stdio_stream.c.
|
static |
Definition at line 233 of file stdio_stream.c.
|
static |
Definition at line 113 of file stdio_stream.c.
|
static |
Definition at line 45 of file stdio_stream.c.
|
static |
Definition at line 79 of file stdio_stream.c.
|
static |
Definition at line 149 of file stdio_stream.c.