Source
*error = zbx_dsprintf(NULL, "name is too long (max %d characters)", ZBX_MAX_HOSTNAME_LEN);
/*
** Zabbix
** Copyright (C) 2001-2024 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 - the char is allowed in the host name *
* FAIL - otherwise *
* *
* Comments: in host name allowed characters: '0-9a-zA-Z. _-' *
* !!! Don't forget to sync the code with PHP !!! *
* *
******************************************************************************/
int zbx_is_hostname_char(unsigned char c)
{
if (0 != isalnum(c))
return SUCCEED;
if (c == '.' || c == ' ' || c == '_' || c == '-')
return SUCCEED;
return FAIL;
}
/******************************************************************************
* *
* Purpose: return hostname and key *
* <hostname:>key *
* *
* Parameters: *
* exp - pointer to the first char of hostname *
* host:key[key params] *
* ^ *
* *
* Return value: return SUCCEED or FAIL *
* *
******************************************************************************/
int zbx_parse_host_key(char *exp, char **host, char **key)
{
char *p, *s;
if (NULL == exp || '\0' == *exp)
return FAIL;
for (p = exp, s = exp; '\0' != *p; p++) /* check for optional hostname */
{