Source
static void mock_compare_stacks(const zbx_vector_eval_token_t *stack1, const zbx_vector_eval_token_t *stack2)
/*
** Zabbix
** 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 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.
**/
static void mock_read_token(zbx_eval_token_t *token, zbx_mock_handle_t htoken)
{
zbx_mock_handle_t hvalue;
zbx_mock_error_t err;
token->type = (zbx_uint32_t)zbx_mock_get_object_member_uint64(htoken, "type");
token->opt = (zbx_uint32_t)zbx_mock_get_object_member_uint64(htoken, "opt");
if (ZBX_MOCK_SUCCESS == zbx_mock_object_member(htoken, "value", &hvalue))
{
const char *value;
zbx_uint64_t ui64;
int len;
token->loc.l = token->loc.r = 0;
if (ZBX_MOCK_SUCCESS != (err = zbx_mock_string(hvalue, &value)))
fail_msg("cannot read token value: %s", zbx_mock_error_string(err));
if (SUCCEED == zbx_is_uint64(value, &ui64))
zbx_variant_set_ui64(&token->value, ui64);
else if (SUCCEED == zbx_number_parse(value, &len) && strlen(value) == (size_t)len)
zbx_variant_set_dbl(&token->value, atof(value));
else
zbx_variant_set_str(&token->value, zbx_strdup(NULL, value));
}
else
{
zbx_variant_set_none(&token->value);
token->loc.l = (size_t)zbx_mock_get_object_member_uint64(htoken, "left");
token->loc.r = (size_t)zbx_mock_get_object_member_uint64(htoken, "right");
}
}
static void mock_read_stack(zbx_vector_eval_token_t *stack, const char *path)
{
zbx_mock_handle_t hstack, htoken, hrepeat;