Source
if (SUCCEED != zbx_eval_parse_expression(&ctx, zbx_mock_get_parameter_string("in.expression"), rules, &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/>.
**/
typedef struct
{
const char *name;
int args_num;
zbx_variant_t retval;
const char *error;
}
zbx_mock_callback_t;
zbx_vector_ptr_t callbacks;
static void mock_callback_free(zbx_mock_callback_t *cb)
{
zbx_variant_clear(&cb->retval);
zbx_free(cb);
}
static void mock_read_callbacks(const char *path)
{
zbx_mock_handle_t hcbs, hcb, hdata, hvalue;
zbx_mock_error_t err;
if (ZBX_MOCK_SUCCESS != zbx_mock_parameter(path, &hcbs))
return;
while (ZBX_MOCK_END_OF_VECTOR != (err = (zbx_mock_vector_element(hcbs, &hcb))))
{
zbx_mock_callback_t *cb;
const char *value;
if (ZBX_MOCK_SUCCESS != err)
fail_msg("cannot read callback contents");
cb = (zbx_mock_callback_t *)zbx_malloc(NULL, sizeof(zbx_mock_callback_t));
memset(cb, 0, sizeof(zbx_mock_callback_t));
cb->name = zbx_mock_get_object_member_string(hcb, "name");
cb->args_num = zbx_mock_get_object_member_uint64(hcb, "args_num");
if (ZBX_MOCK_SUCCESS == zbx_mock_object_member(hcb, "retval", &hdata))
{