|
CX Framework
Cross-platform C utility framework
|
Functions | |
| bool | sbufPRegisterPull (StreamBuffer *sb, sbufPullCB ppull, sbufCleanupCB pcleanup, void *ctx) |
| bool | sbufPRegisterPush (StreamBuffer *sb, sbufCleanupCB pcleanup, void *ctx) |
| size_t | sbufPAvail (StreamBuffer *sb) |
| bool | sbufPWrite (StreamBuffer *sb, const uint8 *buf, size_t sz) |
| bool | sbufPWriteStr (StreamBuffer *sb, strref str) |
| bool | sbufPWriteLine (StreamBuffer *sb, strref str) |
| bool | sbufPWriteEOL (StreamBuffer *sb) |
| void | sbufPFinish (StreamBuffer *sb) |
Functions for the producer side of stream buffer operations.
| size_t sbufPAvail | ( | StreamBuffer * | sb | ) |
size_t sbufPAvail(StreamBuffer *sb)
Returns the available space for writing to the buffer.
| sb | The stream buffer |
| void sbufPFinish | ( | StreamBuffer * | sb | ) |
void sbufPFinish(StreamBuffer *sb)
Marks the producer as finished (EOF).
CRITICAL: The producer MUST NOT access the stream buffer after calling this function as it may be immediately deallocated.
| sb | The stream buffer (invalidated after call) |
| bool sbufPRegisterPull | ( | StreamBuffer * | sb, |
| sbufPullCB | ppull, | ||
| sbufCleanupCB | pcleanup, | ||
| void * | ctx | ||
| ) |
bool sbufPRegisterPull(StreamBuffer *sb, sbufPullCB ppull, sbufCleanupCB pcleanup, void *ctx)
Registers a producer with the stream buffer in pull mode.
In pull mode, the consumer pulls data by calling sbufCRead(), which triggers the producer's callback to fill the buffer.
| sb | The stream buffer |
| ppull | Pull callback to provide data |
| pcleanup | Optional cleanup callback for ctx |
| ctx | Optional user context passed to callbacks |
| bool sbufPRegisterPush | ( | StreamBuffer * | sb, |
| sbufCleanupCB | pcleanup, | ||
| void * | ctx | ||
| ) |
bool sbufPRegisterPush(StreamBuffer *sb, sbufCleanupCB pcleanup, void *ctx)
Registers a producer with the stream buffer in push mode.
In push mode, the producer pushes data by calling sbufPWrite(), which notifies or directly calls the consumer.
| sb | The stream buffer |
| pcleanup | Optional cleanup callback for ctx |
| ctx | Optional user context passed to cleanup |
| bool sbufPWrite | ( | StreamBuffer * | sb, |
| const uint8 * | buf, | ||
| size_t | sz | ||
| ) |
bool sbufPWrite(StreamBuffer *sb, const uint8 *buf, size_t sz)
Writes data to the buffer.
This will always succeed unless the system is out of memory. An overflow buffer is used if written data exceeds current buffer size.
| sb | The stream buffer |
| buf | Data to write |
| sz | Number of bytes to write |
| bool sbufPWriteEOL | ( | StreamBuffer * | sb | ) |
bool sbufPWriteEOL(StreamBuffer *sb)
Writes a system-dependent line ending to the buffer.
Uses \r\n on Windows, \n on Unix systems.
| sb | The stream buffer |
| bool sbufPWriteLine | ( | StreamBuffer * | sb, |
| strref | str | ||
| ) |
bool sbufPWriteLine(StreamBuffer *sb, strref str)
Writes a string followed by a system-dependent line ending to the buffer.
Uses \r\n on Windows, \n on Unix systems.
| sb | The stream buffer |
| str | String to write |
| bool sbufPWriteStr | ( | StreamBuffer * | sb, |
| strref | str | ||
| ) |
bool sbufPWriteStr(StreamBuffer *sb, strref str)
Writes a string to the buffer.
| sb | The stream buffer |
| str | String to write |