Source
static void check_events_condition(const zbx_vector_db_event_t *esc_events, int source, zbx_condition_t *condition)
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
void zbx_ack_task_free(zbx_ack_task_t *ack_task)
{
zbx_free(ack_task);
}
ZBX_PTR_VECTOR_IMPL(ack_task_ptr, zbx_ack_task_t *)
ZBX_PTR_VECTOR_IMPL(db_action_ptr, zbx_db_action *)
/******************************************************************************
* *
* Purpose: compares events by objectid *
* *
* Parameters: d1 - [IN] event structure to compare to d2 *
* d2 - [IN] event structure to compare to d1 *
* *
* Return value: 0 - equal *
* not 0 - otherwise *
* *
******************************************************************************/
static int compare_events(const void *d1, const void *d2)
{
const zbx_db_event *p1 = *(const zbx_db_event * const *)d1;
const zbx_db_event *p2 = *(const zbx_db_event * const *)d2;
ZBX_RETURN_IF_NOT_EQUAL(p1->objectid, p2->objectid);
ZBX_RETURN_IF_NOT_EQUAL(p1->object, p2->object);
return 0;
}
/******************************************************************************
* *
* Purpose: saves eventids that match condition *
* *
* Parameters: esc_events - [IN] events to check *
* condition - [IN/OUT] condition for matching, outputs *
* event ids that match condition *
* objectid - [IN] object id, for example trigger or item id *
* object - [IN] object, for example EVENT_OBJECT_TRIGGER *
* *
******************************************************************************/
static void add_condition_match(const zbx_vector_db_event_t *esc_events, zbx_condition_t *condition,
zbx_uint64_t objectid, int object)
{
int index;
const zbx_db_event event_search = {.objectid = objectid, .object = object};
if (FAIL != (index = zbx_vector_ptr_bsearch((const zbx_vector_ptr_t *)esc_events, &event_search,
compare_events)))
{
const zbx_db_event *event = esc_events->values[index];
zbx_vector_uint64_append(&condition->eventids, event->eventid);
for (int i = index - 1; 0 <= i; i--)
{
event = esc_events->values[i];