Functions that provide dynamically buffered stream-like data structures

Overview

// typedefs

typedef struct vrna_cstr_s* vrna_cstr_t
typedef struct vrna_ordered_stream_s* vrna_ostream_t

typedef void () vrna_callback_stream_output (
    void *auxdata,
    unsigned int i,
    void *data
    )

// global functions

vrna_cstr_t vrna_cstr (
    size_t size,
    FILE* output
    )

void vrna_cstr_free (vrna_cstr_t buf)
void vrna_cstr_close (vrna_cstr_t buf)
void vrna_cstr_fflush (struct vrna_cstr_s* buf)
const char* vrna_cstr_string (vrna_cstr_t buf)

int vrna_cstr_vprintf (
    vrna_cstr_t buf,
    const char* format,
    va_list args
    )

int vrna_cstr_printf (
    vrna_cstr_t buf,
    const char* format,
    ...
    )

void vrna_cstr_message_info (
    vrna_cstr_t buf,
    const char* format,
    ...
    )

void vrna_cstr_message_vinfo (
    vrna_cstr_t buf,
    const char* format,
    va_list args
    )

void vrna_cstr_print_fasta_header (
    vrna_cstr_t buf,
    const char* head
    )

void vrna_cstr_printf_structure (
    struct vrna_cstr_s* buf,
    const char* structure,
    const char* format,
    ...
    )

void vrna_cstr_vprintf_structure (
    struct vrna_cstr_s* buf,
    const char* structure,
    const char* format,
    va_list args
    )

void vrna_cstr_printf_comment (
    struct vrna_cstr_s* buf,
    const char* format,
    ...
    )

void vrna_cstr_vprintf_comment (
    struct vrna_cstr_s* buf,
    const char* format,
    va_list args
    )

void vrna_cstr_printf_thead (
    struct vrna_cstr_s* buf,
    const char* format,
    ...
    )

void vrna_cstr_vprintf_thead (
    struct vrna_cstr_s* buf,
    const char* format,
    va_list args
    )

void vrna_cstr_printf_tbody (
    struct vrna_cstr_s* buf,
    const char* format,
    ...
    )

void vrna_cstr_vprintf_tbody (
    struct vrna_cstr_s* buf,
    const char* format,
    va_list args
    )

vrna_ostream_t vrna_ostream_init (
    vrna_callback_stream_output* output,
    void* auxdata
    )

void vrna_ostream_free (vrna_ostream_t dat)
int vrna_ostream_threadsafe (void)

void vrna_ostream_request (
    vrna_ostream_t dat,
    unsigned int num
    )

void vrna_ostream_provide (
    vrna_ostream_t dat,
    unsigned int i,
    void* data
    )

Detailed Documentation

Typedefs

typedef struct vrna_ordered_stream_s* vrna_ostream_t
An ordered output stream structure with unordered insert capabilities.
typedef void () vrna_callback_stream_output (
    void *auxdata,
    unsigned int i,
    void *data
    )
Ordered stream processing callback.

This callback will be processed in sequential order as soon as sequential data in the output stream becomes available.

Parameters:

auxdata A shared pointer for all calls, as provided by the second argument to vrna_ostream_init()
i The index number of the data passed to data
data A block of data ready for processing

Note

The callback must also release the memory occupied by the data passed since the stream will lose any reference to it after the callback has been executed.

Global Functions

vrna_ostream_t vrna_ostream_init (
    vrna_callback_stream_output* output,
    void* auxdata
    )
Get an initialized ordered output stream.

Parameters:

output A callback function that processes and releases data in the stream
auxdata A pointer to auxiliary data passed as first argument to the output callback

Returns:

An initialized ordered output stream

void vrna_ostream_free (vrna_ostream_t dat)
Free an initialized ordered output stream.

Parameters:

dat The output stream for which occupied memory should be free’d
void vrna_ostream_request (
    vrna_ostream_t dat,
    unsigned int num
    )
Request index in ordered output stream.

This function must be called prior to vrna_ostream_provide() to indicate that data associted with a certain index number is expected to be inserted into the stream in the future.

dat The output stream for which the index is requested

Parameters:

num The index to request data for
void vrna_ostream_provide (
    vrna_ostream_t dat,
    unsigned int i,
    void* data
    )
Provide output stream data for a particular index.

Parameters:

dat The output stream for which data is provided
i The index of the provided data
data The data provided

Pre-Condition

The index data is provided for must have been requested using vrna_ostream_request() beforehand.