Source
if ('\0' != *(str += len) && 0 != (flags & ZBX_FLAG_DOUBLE_SUFFIX) && NULL != strchr(ZBX_UNIT_SYMBOLS, *str))
/*
** 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.
**/
/******************************************************************************
* *
* Return value: SUCCEED - char is allowed in item key *
* FAIL - otherwise *
* *
* Comments: allowed characters in key are: '0-9a-zA-Z._-' *
* !!! Don't forget to sync the code with PHP !!! *
* *
******************************************************************************/
int zbx_is_key_char(unsigned char c)
{
if (0 != isalnum(c))
return SUCCEED;
if (c == '.' || c == '_' || c == '-')
return SUCCEED;
return FAIL;
}
/******************************************************************************
* *
* Purpose: Advances pointer to first invalid character in string *
* ensuring that everything before it is a valid key. *
* *
* e.g., system.run[cat /etc/passwd | awk -F: '{ print $1 }'] *
* *
* Parameters: exp - [IN/OUT] pointer to first char of key *
* *
* e.g., {host:system.run[cat /etc/passwd | awk -F: '{ print $1 }'].last(0)} *
* ^ *
* Return value: Returns FAIL only if no key is present (length 0), *
* or the whole string is invalid. SUCCEED otherwise. *
* *
* Comments: The pointer is advanced to the first invalid character even if *
* FAIL is returned (meaning there is a syntax error in item key). *
* If necessary, the caller must keep a copy of pointer original *
* value. *
* *