Source
xxxxxxxxxx
static int pp_excute_jsonpath_query(zbx_pp_cache_t *cache, zbx_variant_t *value, const char *params, char **errmsg)
/*
** 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.
**/
/******************************************************************************
* *
* Purpose: execute 'multiply by' step *
* *
* Parameters: value_type - [IN] the item value type *
* value - [IN/OUT] the input/output value *
* params - [IN] the preprocessing parameters *
* *
* Result value: SUCCEED - the preprocessing step was executed successfully. *
* FAIL - otherwise. The error message is stored in value. *
* *
******************************************************************************/
static int pp_execute_multiply(unsigned char value_type, zbx_variant_t *value, const char *params)
{
char buffer[MAX_STRING_LEN], *error = NULL, *errmsg = NULL;
zbx_strlcpy(buffer, params, sizeof(buffer));
zbx_trim_float(buffer);
if (FAIL == zbx_is_double(buffer, NULL))
{
error = zbx_dsprintf(NULL, "a numerical value is expected or the value is out of range");
}
else if (SUCCEED == item_preproc_multiplier_variant(value_type, value, buffer, &errmsg))
{
return SUCCEED;
}
else
{
error = zbx_dsprintf(NULL, "cannot apply multiplier \"%s\" to value of type \"%s\": %s",
params, zbx_variant_type_desc(value), errmsg);
zbx_free(errmsg);
}
zbx_variant_clear(value);
zbx_variant_set_error(value, error);
return FAIL;
}
/******************************************************************************
* *
* Purpose: return preprocessing 'trim' step descriptions for error messages *
* *
******************************************************************************/
static const char *pp_trim_desc(int type)
{
switch (type)
{
case ZBX_PREPROC_RTRIM:
return "right ";
case ZBX_PREPROC_LTRIM:
return "left ";
default:
return "";
}
}