ucx
UAP Common Extensions
Loading...
Searching...
No Matches
Macros | Functions
streams.h File Reference

Utility functions for data streams. More...

#include "common.h"

Go to the source code of this file.

Macros

#define cx_stream_bcopy(src, dest, rfnc, wfnc, buf, bufsize)    cx_stream_bncopy(src, dest, rfnc, wfnc, buf, bufsize, SIZE_MAX)
 Reads data from a stream and writes it to another stream.
 
#define cx_stream_copy(src, dest, rfnc, wfnc)    cx_stream_ncopy(src, dest, rfnc, wfnc, SIZE_MAX)
 Reads data from a stream and writes it to another stream.
 

Functions

size_t cx_stream_bncopy (void *src, void *dest, cx_read_func rfnc, cx_write_func wfnc, char *buf, size_t bufsize, size_t n)
 Reads data from a stream and writes it to another stream.
 
size_t cx_stream_ncopy (void *src, void *dest, cx_read_func rfnc, cx_write_func wfnc, size_t n)
 Reads data from a stream and writes it to another stream.
 

Detailed Description

Utility functions for data streams.

Author
Mike Becker
Olaf Wintermann

Macro Definition Documentation

◆ cx_stream_bcopy

#define cx_stream_bcopy ( src,
dest,
rfnc,
wfnc,
buf,
bufsize )    cx_stream_bncopy(src, dest, rfnc, wfnc, buf, bufsize, SIZE_MAX)

Reads data from a stream and writes it to another stream.

Parameters
src(void*) the source stream
dest(void*) the destination stream
rfnc(cx_read_func) the read function
wfnc(cx_write_func) the write function
buf(char*) a pointer to the copy buffer or NULL if a buffer shall be implicitly created on the heap
bufsize(size_t) the size of the copy buffer - if buf is NULL you can set this to zero to let the implementation decide
Returns
total number of bytes copied

◆ cx_stream_copy

#define cx_stream_copy ( src,
dest,
rfnc,
wfnc )    cx_stream_ncopy(src, dest, rfnc, wfnc, SIZE_MAX)

Reads data from a stream and writes it to another stream.

The data is temporarily stored in a stack allocated buffer.

Parameters
src(void*) the source stream
dest(void*) the destination stream
rfnc(cx_read_func) the read function
wfnc(cx_write_func) the write function
Returns
total number of bytes copied

Function Documentation

◆ cx_stream_bncopy()

size_t cx_stream_bncopy ( void * src,
void * dest,
cx_read_func rfnc,
cx_write_func wfnc,
char * buf,
size_t bufsize,
size_t n )

Reads data from a stream and writes it to another stream.

Parameters
srcthe source stream
destthe destination stream
rfncthe read function
wfncthe write function
bufa pointer to the copy buffer or NULL if a buffer shall be implicitly created on the heap
bufsizethe size of the copy buffer - if buf is NULL you can set this to zero to let the implementation decide
nthe maximum number of bytes that shall be copied. If this is larger than bufsize, the content is copied over multiple iterations.
Returns
the total number of bytes copied

◆ cx_stream_ncopy()

size_t cx_stream_ncopy ( void * src,
void * dest,
cx_read_func rfnc,
cx_write_func wfnc,
size_t n )

Reads data from a stream and writes it to another stream.

The data is temporarily stored in a stack allocated buffer.

Parameters
srcthe source stream
destthe destination stream
rfncthe read function
wfncthe write function
nthe maximum number of bytes that shall be copied.
Returns
total number of bytes copied