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,
/*
** Zabbix
** Copyright (C) 2001-2023 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.
**/
/* 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;
}