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/>.
**/
static unsigned int hex2num(char c)
{
int res;
if (c >= 'a')
res = c - 'a' + 10; /* a-f */
else if (c >= 'A')
res = c - 'A' + 10; /* A-F */
else
res = c - '0'; /* 0-9 */
return (unsigned int)res;
}
void mock_read_variant(const char *path, zbx_variant_t *variant)
{
zbx_mock_handle_t hvalue;
const char *type, *value;
hvalue = zbx_mock_get_parameter_handle(path);
type = zbx_mock_get_object_member_string(hvalue, "type");
if (0 == strcmp(type, "ZBX_VARIANT_NONE"))
{
zbx_variant_set_none(variant);
return;
}
value = zbx_mock_get_object_member_string(hvalue, "value");
if (0 == strcmp(type, "ZBX_VARIANT_STR"))
{
zbx_variant_set_str(variant, zbx_strdup(NULL, value));
return;
}
if (0 == strcmp(type, "ZBX_VARIANT_DBL"))