Source
xxxxxxxxxx
/*
** Copyright (C) 2001-2024 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/>.
**/
typedef struct
{
const char *name;
const char *value;
}
str_pair_t;
ZBX_PTR_VECTOR_DECL(str_pair, str_pair_t)
ZBX_PTR_VECTOR_IMPL(str_pair, str_pair_t)
static zbx_vector_str_pair_t resolve_vector;
static int resolve_return = SUCCEED;
static int macro_resolv_func(zbx_macro_resolv_data_t *p, va_list args, char **replace_to, char **data, char *error,
size_t maxerrlen)
{
int index = 0, resolved = FAIL;
ZBX_UNUSED(args);
ZBX_UNUSED(data);
ZBX_UNUSED(error);
ZBX_UNUSED(maxerrlen);
zabbix_log(LOG_LEVEL_INFORMATION, "In %s() macro:%s indexed:%d index:%d", __func__, p->macro, p->indexed,
p->index);
for (int i = 0; i < resolve_vector.values_num; i++)
{
const char *value = resolve_vector.values[i].value;
if (0 == strcmp(p->macro, resolve_vector.values[i].name))
{
if (p->indexed)
{
index++;
if (index != p->index) continue;
if (p->raw_value)
{
// Remove @ at the beginning
if ('@' == value[0])