Source
/*
** 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/>.
**/
static zbx_mock_config_t mock_config;
zbx_mock_config_t *get_mock_config(void)
{
return &mock_config;
}
void *__wrap_zbx_hashset_search(zbx_hashset_t *hs, const void *data);
void *__real_zbx_hashset_search(zbx_hashset_t *hs, const void *data);
void mock_config_free_user_macros(void);
void mock_config_free_hosts(void);
void *__wrap_zbx_hashset_search(zbx_hashset_t *hs, const void *data)
{
int i;
if (&mock_config.dc.items == hs)
{
static ZBX_DC_ITEM item = {.hostid = 1};
return &item;
}
if (0 != (mock_config.initialized & ZBX_MOCK_CONFIG_USERMACROS))
{
if (hs == &mock_config.dc.um_cache->hosts)
{
zbx_uint64_t hostid = **(zbx_uint64_t **)data;
for (i = 0; i < mock_config.um_hosts.values_num; i++)
{
if (mock_config.um_hosts.values[i]->hostid == hostid)
return &mock_config.um_hosts.values[i];
}
return NULL;
}
}
if (0 != (mock_config.initialized & ZBX_MOCK_CONFIG_HOSTS))
{
if (hs == &mock_config.dc.hosts)
{
zbx_uint64_t hostid = *(zbx_uint64_t *)data;