Source
int zbx_lld_macro_value_by_name(const struct zbx_json_parse *jp_row, const zbx_vector_ptr_t *lld_macro_paths,
/*
** 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.
**/
/******************************************************************************
* *
* Purpose: sorting function to sort LLD macros by unique name *
* *
******************************************************************************/
int zbx_lld_macro_paths_compare(const void *d1, const void *d2)
{
const zbx_lld_macro_path_t *r1 = *(const zbx_lld_macro_path_t **)d1;
const zbx_lld_macro_path_t *r2 = *(const zbx_lld_macro_path_t **)d2;
return strcmp(r1->lld_macro, r2->lld_macro);
}
/******************************************************************************
* *
* Purpose: retrieve list of LLD macros *
* *
* Parameters: lld_ruleid - [IN] LLD id *
* lld_macro_paths - [OUT] use json path to extract from jp_row *
* error - [OUT] in case json path is invalid *
* *
******************************************************************************/
int zbx_lld_macro_paths_get(zbx_uint64_t lld_ruleid, zbx_vector_ptr_t *lld_macro_paths, char **error)
{
DB_RESULT result;
DB_ROW row;
zbx_lld_macro_path_t *lld_macro_path;
int ret = SUCCEED;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
result = zbx_db_select(
"select lld_macro,path"
" from lld_macro_path"
" where itemid=" ZBX_FS_UI64,
lld_ruleid);
while (NULL != (row = zbx_db_fetch(result)))
{