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/>.
**/
/******************************************************************************
* *
* Purpose: expands discovery macro in expression *
* *
* Parameters: data - [IN/OUT] expression containing lld macro *
* token - [IN/OUT] token with lld macro location data *
* flags - [IN] flags passed to *
* subtitute_discovery_macros() function *
* jp_row - [IN] discovery data *
* lld_macro_paths - [IN] *
* esc - [IN] used in autoquoting for trigger *
* prototypes *
* *
******************************************************************************/
static void process_lld_macro_token(char **data, zbx_token_t *token, int flags, const struct zbx_json_parse *jp_row,
const zbx_vector_lld_macro_path_ptr_t *lld_macro_paths, int esc)
{
char c, *replace_to = NULL;
int l ,r;
if (ZBX_TOKEN_LLD_FUNC_MACRO == token->type)
{
l = token->data.lld_func_macro.macro.l;
r = token->data.lld_func_macro.macro.r;
}
else
{
l = token->loc.l;
r = token->loc.r;
}
c = (*data)[r + 1];
(*data)[r + 1] = '\0';
if (SUCCEED != zbx_lld_macro_value_by_name(jp_row, lld_macro_paths, *data + l, &replace_to))
{