Source
xxxxxxxxxx
int zbx_eval_execute_ext(zbx_eval_context_t *ctx, const zbx_timespec_t *ts, zbx_eval_function_cb_t common_func_cb,
/*
** 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/>.
**/
/* exit code in addition to SUCCEED/FAIL */
/* bit function types */
typedef enum
{
FUNCTION_OPTYPE_BIT_AND = 0,
FUNCTION_OPTYPE_BIT_OR,
FUNCTION_OPTYPE_BIT_XOR,
FUNCTION_OPTYPE_BIT_LSHIFT,
FUNCTION_OPTYPE_BIT_RSHIFT
}
zbx_function_bit_optype_t;
/* trim function types */
typedef enum
{
FUNCTION_OPTYPE_TRIM_ALL = 0,
FUNCTION_OPTYPE_TRIM_LEFT,
FUNCTION_OPTYPE_TRIM_RIGHT
}
zbx_function_trim_optype_t;
/******************************************************************************
* *
* Purpose: converts variant string value containing suffixed number to *
* floating point variant value *
* *
* Parameters: value - [OUT] *
* value_num - [IN] value to convert *
* *
* Return value: SUCCEED - value was converted successfully *
* FAIL - otherwise *
* *
******************************************************************************/
static int variant_convert_suffixed_num(zbx_variant_t *value, const zbx_variant_t *value_num)
{
char suffix;
double result;
if (ZBX_VARIANT_STR != value_num->type)
return FAIL;
if (SUCCEED != eval_suffixed_number_parse(value_num->data.str, &suffix))
return FAIL;
result = atof(value_num->data.str) * suffix2factor(suffix);
if (FP_ZERO != fpclassify(result) && FP_NORMAL != fpclassify(result))
return FAIL;
zbx_variant_set_dbl(value, result);
return SUCCEED;
}
/******************************************************************************
* *
* Purpose: evaluates unary operator *
* *
* Parameters: ctx - [IN] evaluation context *
* token - [IN] operator token *