CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Console Adapter

Functions

bool sbufConOut (StreamBuffer *sb, ConStream *con)
 
bool sbufConCRegisterPush (StreamBuffer *sb, ConStream *con)
 

Detailed Description

Adapter for using a console stream (see Console) as a stream buffer consumer.

Unlike sbfile.h's VFS adapters, there is no producer half and no close parameter – conOut()/conErr()/conIn() are process singletons and a conCreateMem() stream is owned by whoever created it, so a stream buffer consumer never closes or destroys the ConStream it writes to.

Consumer (Output) Functions:

Function Documentation

◆ sbufConCRegisterPush()

bool sbufConCRegisterPush ( StreamBuffer *  sb,
ConStream *  con 
)

bool sbufConCRegisterPush(StreamBuffer *sb, ConStream *con)

Registers a console stream as a consumer with the stream buffer in push mode.

In push mode, data is automatically written to con as it becomes available from the producer. Use this instead of sbufConOut() when you need the producer and consumer to operate asynchronously. Never closes or destroys con.

Parameters
sbThe stream buffer
conConsole stream to write to
Returns
true on success, false if registration failed

◆ sbufConOut()

bool sbufConOut ( StreamBuffer *  sb,
ConStream *  con 
)

bool sbufConOut(StreamBuffer *sb, ConStream *con)

Consumes all available data from the buffer and writes it to a console stream.

Reads data from the stream buffer until the producer finishes (EOF) and writes it to con in chunks. Never closes or destroys con.

Parameters
sbThe stream buffer
conConsole stream to write to
Returns
true on success, false on error

Example:

StreamBuffer *sb = sbufCreate(4096);
sbufStrPRegisterPull(sb, inputData);
ConStream * conOut(void)
bool sbufConOut(StreamBuffer *sb, ConStream *con)
#define sbufCreate(targetsz,...)
Definition streambuf.h:275
bool sbufStrPRegisterPull(StreamBuffer *sb, strref str)