trmsg_foreach_messages()#
trmsg_foreach_messages() iterates over all messages in the given list, invoking the provided callback function for each message. The callback receives either duplicated or cloned message instances based on the duplicated flag.
Prototype
int trmsg_foreach_messages(
json_t *list,
BOOL duplicated,
int (*callback)(
json_t *list,
const char *key,
json_t *instances,
void *user_data1,
void *user_data2
),
void *user_data1,
void *user_data2,
json_t *jn_filter
);
Parameters
Key |
Type |
Description |
|---|---|---|
|
|
The list containing messages to iterate over. |
|
|
If |
|
|
A function pointer to the callback that processes each message. It should return a negative value to break the iteration. |
|
|
User-defined data passed to the callback function. |
|
|
Additional user-defined data passed to the callback function. |
|
|
A JSON object specifying filtering criteria for selecting messages. The caller owns this parameter. |
Return Value
Returns 0 on success, a negative value if the iteration was interrupted by the callback, or a positive error code on failure.
Notes
The callback function receives a reference to the list, the message key, and the instances JSON object. The instances parameter must be owned by the callback function. This function is similar to trmsg_foreach_active_messages() and trmsg_foreach_instances_messages(), but it allows selecting between duplicated and cloned messages.
Prototype
// Not applicable in JS
Prototype
# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples