LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
stdio_stream_cr_api.h File Reference

Composition Root API for wiring the stdio_stream adapter into the stream factory. More...

Include dependency graph for stdio_stream_cr_api.h:
This graph shows which files directly or indirectly include this file:

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.
 
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.
 
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.
 

Detailed Description

This header exposes the CR-facing entry points used to:

  • build default stdio_stream configuration and environment values,
  • create stream_t handles backed by the process standard I/O streams (stdin, stdout, and stderr),
  • build an adapter descriptor suitable for registration in the stream factory.

Definition in file stdio_stream_cr_api.h.

Function Documentation

◆ stdio_stream_create_desc()

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 
)
Parameters
outOutput location that receives the constructed adapter descriptor on success.
keyBorrowed adapter registration key.
cfgBorrowed adapter configuration copied into descriptor-owned constructor data.
envBorrowed adapter environment copied into descriptor-owned constructor data.
memBorrowed memory operations table used to allocate the descriptor-owned constructor data.
Return values
STREAM_STATUS_OKThe descriptor was created successfully.
STREAM_STATUS_INVALIDOne or more arguments are invalid.
STREAM_STATUS_OOMMemory 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.

◆ stdio_stream_create_stream()

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:

  • On success, a newly allocated stream is returned in *out.
  • The caller becomes responsible for destroying it via stream_destroy().
  • On failure, *out is left unchanged.
Parameters
[out]outReceives the created stream handle. Must not be NULL.
[in]argsCreation arguments selecting which standard I/O stream is wrapped by the created adapter instance. Must not be NULL.
[in]cfgAdapter configuration. Must not be NULL.
[in]envAdapter environment containing injected dependencies. Must not be NULL.
Return values
STREAM_STATUS_OKStream successfully created.
STREAM_STATUS_INVALIDOne or more arguments are invalid.
STREAM_STATUS_OOMMemory allocation failed.

Definition at line 156 of file stdio_stream.c.

◆ stdio_stream_ctor()

stream_status_t stdio_stream_ctor ( const void *  ud,
const void *  args,
stream_t **  out 
)
Parameters
udBorrowed adapter-specific constructor user data.
argsBorrowed creation arguments expected by the adapter factory contract.
outOutput location that receives the created stream_t * on success.
Return values
STREAM_STATUS_OKThe stream was created successfully.
STREAM_STATUS_INVALIDOne or more arguments are invalid.
STREAM_STATUS_OOMMemory 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_default_cfg()

stdio_stream_cfg_t stdio_stream_default_cfg ( void  )

This helper provides a value-initialized baseline configuration that the Composition Root may override.

Returns
A well-formed default stdio_stream_cfg_t.

Definition at line 27 of file stdio_stream.c.

◆ stdio_stream_default_env()

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.

Parameters
stdio_opsBorrowed 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.
memBorrowed memory operations table used by the adapter backend.
[in]port_envBorrowed stream port environment.
Returns
A well-formed stdio_stream_env_t aggregating the provided dependencies.

Definition at line 31 of file stdio_stream.c.