Source
static int trapper_expressions_evaluate_run(const struct zbx_json_parse *jp, struct zbx_json *json, char **error)
/*
** 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 int trapper_parse_expressions_evaluate(const struct zbx_json_parse *jp, zbx_vector_str_t *expressions,
char **error)
{
char buffer[MAX_STRING_LEN];
const char *ptr;
zbx_user_t user;
int ret = FAIL;
struct zbx_json_parse jp_data, jp_expressions;
zbx_user_init(&user);
if (FAIL == zbx_get_user_from_json(jp, &user, NULL) || USER_TYPE_ZABBIX_ADMIN > user.type)
{
*error = zbx_strdup(NULL, "Permission denied.");
goto out;
}
if (FAIL == zbx_json_brackets_by_name(jp, ZBX_PROTO_TAG_DATA, &jp_data))
{
*error = zbx_strdup(NULL, "Missing data field.");
goto out;
}
if (FAIL == zbx_json_brackets_by_name(&jp_data, ZBX_PROTO_TAG_EXPRESSIONS, &jp_expressions))
{
*error = zbx_strdup(NULL, "Missing expressions field.");
goto out;
}
for (ptr = NULL; NULL != (ptr = zbx_json_next_value(&jp_expressions, ptr, buffer, sizeof(buffer), NULL));)
{
zbx_vector_str_append(expressions, zbx_strdup(NULL, buffer));
}
ret = SUCCEED;
out:
zbx_user_free(&user);
return ret;