Next: , Previous: , Up: Messages and Message Lists   [Contents][Index]


6.3.3 Adding Messages to a Message List

To add a message to a message list, the following function can be used.

Function: int qsmm_msglist_add_msg (qsmm_msglist_t msglist, qsmm_msg_t msg)

This function adds message msg to message list msglist.

After adding a message to a message list, you must not explicitly destroy the message by the function qsmm_msg_destroy. The message will be destroyed automatically by the function qsmm_msglist_clear when clearing the message list or by the function qsmm_msglist_destroy when destroying the message list.

On success, the function returns a non-negative value. If there is not enough memory to perform the operation, then negative error code QSMM_ERR_NOMEM will be returned.

To append to a message list copies of all messages contained in the other message list, the following function can be used.

Function: int qsmm_msglist_extend (qsmm_msglist_t dst, qsmm_msglist_t src)

This function appends to the end of message list dst copies of all messages contained in message list src, in the same order.

The function returns a non-negative value on success or a negative error code on failure. Currently, the following error codes can be returned.

QSMM_ERR_INVAL

Message list handles dst and/or src are NULL or they are equal.

QSMM_ERR_NOMEM

There was not enough memory to perform the operation.

To clear a message list, the following function can be used.

Function: void qsmm_msglist_clear (qsmm_msglist_t msglist)

This function removes all messages from message list msglist and destroys them.

To get the total number of messages contained in a message list, the following function can be used.

Function: size_t qsmm_get_msglist_sz (qsmm_msglist_t msglist)

This function returns the total number of messages contained in message list msglist.

To get the number of messages of a specific category contained in a message list, the following function can be used.

Function: int qsmm_get_msglist_sz_type (qsmm_msglist_t msglist, enum qsmm_msg_e msg_type, size_t *sz_p)

This function sets *sz_p equal to the number of messages of category msg_type contained in message list msglist. If sz_p is NULL, then the function will have no effect.

The function returns a non-negative value on success or negative error code QSMM_ERR_INVAL if msg_type is negative or greater than or equal to QSMM_MSG_COUNT.

To get a message contained in a message list, the following function can be used.

Function: qsmm_msg_t qsmm_get_msglist_msg (qsmm_msglist_t msglist, size_t idx)

This function returns the handle of a message contained in message list msglist at index idx. If idx is greater than or equal to the total number of messages held in the message list, then the function will return NULL.


Next: , Previous: , Up: Messages and Message Lists   [Contents][Index]