## prelude-msgbuf

prelude-msgbuf

## Functions

int | prelude_msgbuf_new ()
void | prelude_msgbuf_destroy ()
void | prelude_msgbuf_mark_end ()
int | prelude_msgbuf_set ()
prelude_msg_t * | prelude_msgbuf_get_msg ()
void | prelude_msgbuf_set_callback ()
void | prelude_msgbuf_set_data ()
void * | prelude_msgbuf_get_data ()
void | prelude_msgbuf_set_flags ()
prelude_msgbuf_flags_t | prelude_msgbuf_get_flags ()

## Types and Values

typedef | prelude_msgbuf_t
enum | prelude_msgbuf_flags_t

## Description

## Functions

### prelude_msgbuf_new ()

    int
    prelude_msgbuf_new (prelude_msgbuf_t **msgbuf);

Create a new prelude_msgbuf_t object and store it into `msgbuf` . You can then write data to `msgbuf` using the `prelude_msgbuf_set()` function.

When the message buffer is full, the message will be flushed using the user provided callback.

#### Parameters

msgbuf | Pointer where to store the created prelude_msgbuf_t object. |

#### Returns

0 on success, or a negative value if an error occured.

### prelude_msgbuf_destroy ()

    void
    prelude_msgbuf_destroy (prelude_msgbuf_t *msgbuf);

Destroy `msgbuf` , all data remaining will be flushed.

#### Parameters

msgbuf | Pointer on a prelude_msgbuf_t object. |

### prelude_msgbuf_mark_end ()

    void
    prelude_msgbuf_mark_end (prelude_msgbuf_t *msgbuf);

This function should be called to tell the msgbuf subsystem that you finished writing your message.

#### Parameters

msgbuf | Pointer on prelude_msgbuf_t object. |

### prelude_msgbuf_set ()

    int
    prelude_msgbuf_set (prelude_msgbuf_t *msgbuf,
                        uint8_t tag,
                        uint32_t len,
                        const void *data);

prelude_msgbuf_set() append `len` bytes of data from the `data` buffer to the `msgbuf` object representing a message. The data is tagged with `tag` .

#### Parameters

msgbuf | Pointer on a prelude_msgbuf_t object to store the data to. |
tag | 8 bits unsigned integer describing the kind of data. |
len | len of the data chunk. |
data | Pointer to the data. |

#### Returns

0 on success, a negative value if an error occured.

### prelude_msgbuf_get_msg ()

    prelude_msg_t *
    prelude_msgbuf_get_msg (prelude_msgbuf_t *msgbuf);

#### Parameters

msgbuf | Pointer on a prelude_msgbuf_t object. |

#### Returns

This function return the current message associated with the message buffer.

### prelude_msgbuf_set_callback ()

    void
    prelude_msgbuf_set_callback (prelude_msgbuf_t *msgbuf,
                                 int (*send_msg) (prelude_msgbuf_t *msgbuf, prelude_msg_t *msg));

Associate an application specific callback to this `msgbuf` .

#### Parameters

msgbuf | Pointer on a prelude_msgbuf_t object. |
send_msg | Pointer to a function for sending a message. |

### prelude_msgbuf_set_data ()

    void
    prelude_msgbuf_set_data (prelude_msgbuf_t *msgbuf,
                             void *data);

### prelude_msgbuf_get_data ()

    void *
    prelude_msgbuf_get_data (prelude_msgbuf_t *msgbuf);

### prelude_msgbuf_set_flags ()

    void
    prelude_msgbuf_set_flags (prelude_msgbuf_t *msgbuf,
                              prelude_msgbuf_flags_t flags);

### prelude_msgbuf_get_flags ()

    prelude_msgbuf_flags_t
    prelude_msgbuf_get_flags (prelude_msgbuf_t *msgbuf);

## Types and Values

### prelude_msgbuf_t

    typedef struct prelude_msgbuf prelude_msgbuf_t;

### enum prelude_msgbuf_flags_t

#### Members

PRELUDE_MSGBUF_FLAGS_ASYNC |  |