Source
static int item_preproc_csv_to_json_add_field(struct zbx_json *json, char ***names, char *field, unsigned int num,
/*
** Zabbix
** Copyright (C) 2001-2022 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.
**/
/* LIBXML2 is used */
extern zbx_es_t es_engine;
/******************************************************************************
* *
* Function: item_preproc_numeric_type_hint *
* *
* Purpose: returns numeric type hint based on item value type *
* *
* Parameters: value_type - [IN] the item value type *
* *
* Return value: variant numeric type or none *
* *
******************************************************************************/
static int item_preproc_numeric_type_hint(unsigned char value_type)
{
switch (value_type)
{
case ITEM_VALUE_TYPE_FLOAT:
return ZBX_VARIANT_DBL;
case ITEM_VALUE_TYPE_UINT64:
return ZBX_VARIANT_UI64;
default:
return ZBX_VARIANT_NONE;
}
}
/******************************************************************************
* *
* Function: item_preproc_convert_value *
* *
* Purpose: convert variant value to the requested type *
* *
* Parameters: value - [IN/OUT] the value to convert *
* type - [IN] the new value type *
* errmsg - [OUT] error message *
* *
* Return value: SUCCEED - the value was converted successfully *
* FAIL - otherwise, errmsg contains the error message *
* *
******************************************************************************/
static int item_preproc_convert_value(zbx_variant_t *value, unsigned char type, char **errmsg)
{
if (FAIL == zbx_variant_convert(value, type))
{
*errmsg = zbx_dsprintf(*errmsg, "cannot convert value to %s", zbx_get_variant_type_desc(type));
return FAIL;
}
return SUCCEED;
}
/******************************************************************************
* *
* Function: zbx_item_preproc_convert_value_to_numeric *