Source
void um_cache_resolve(const zbx_um_cache_t *cache, const zbx_uint64_t *hostids, int hostids_num, const char *macro,
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
extern zbx_shmem_info_t *config_mem;
ZBX_SHMEM_FUNC_IMPL(__config, config_mem)
ZBX_PTR_VECTOR_IMPL(um_macro, zbx_um_macro_t *)
ZBX_PTR_VECTOR_IMPL(um_host, zbx_um_host_t *)
extern unsigned char program_type;
typedef enum
{
ZBX_UM_UPDATE_HOST,
ZBX_UM_UPDATE_MACRO
}
zbx_um_update_cause_t;
/*********************************************************************************
* *
* Purpose: create duplicate user macro cache *
* *
* Parameters: cache - [IN] the user macro cache to duplicate *
* *
* Return value: The duplicated user macro cache. *
* *
* Comments: The internal structures are duplicated copying references of *
* cached objects and incrementing their reference counters. *
* *
*********************************************************************************/
static zbx_um_cache_t *um_cache_dup(zbx_um_cache_t *cache)
{
zbx_um_cache_t *dup;
zbx_um_host_t **phost;
zbx_hashset_iter_t iter;
dup = (zbx_um_cache_t *)__config_shmem_malloc_func(NULL, sizeof(zbx_um_cache_t));
dup->refcount = 1;
zbx_hashset_copy(&dup->hosts, &cache->hosts, sizeof(zbx_um_host_t *));
zbx_hashset_iter_reset(&dup->hosts, &iter);
while (NULL != (phost = (zbx_um_host_t **)zbx_hashset_iter_next(&iter)))
(*phost)->refcount++;
return dup;
}
/* macro sorting */
static int um_macro_compare_by_name_context(const void *d1, const void *d2)
{
const zbx_um_macro_t *m1 = *(const zbx_um_macro_t * const *)d1;
const zbx_um_macro_t *m2 = *(const zbx_um_macro_t * const *)d2;
int ret;
if (0 != (ret = strcmp(m1->name, m2->name)))
return ret;
/* ZBX_CONDITION_OPERATOR_EQUAL (0) has higher priority than ZBX_CONDITION_OPERATOR_REGEXP (8) */
ZBX_RETURN_IF_NOT_EQUAL(m1->context_op, m2->context_op);
return zbx_strcmp_null(m1->context, m2->context);
}
/* host hashset support */