Source
static int parse_content_key_value(const char *data, size_t pos, zbx_strloc_t *loc_name, zbx_strloc_t *loc_value)
/*
** 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.
**/
static int str_loc_cmp(const char *src, const zbx_strloc_t *loc, const char *text, size_t text_len)
{
ZBX_RETURN_IF_NOT_EQUAL(loc->r - loc->l + 1, text_len);
return zbx_strncasecmp(src + loc->l, text, text_len);
}
static char *str_loc_dup(const char *src, const zbx_strloc_t *loc)
{
char *str;
size_t len;
len = loc->r - loc->l + 1;
str = zbx_malloc(NULL, len + 1);
memcpy(str, src + loc->l, len);
str[len] = '\0';
return str;
}
static int parse_attribute_name(const char *data, size_t pos, zbx_strloc_t *loc)
{
const char *ptr = data + pos;
if (NULL != strchr(ZBX_ATTRIBUTE_NAME_CHARLIST, *ptr))
return FAIL;
while (NULL == strchr(ZBX_ATTRIBUTE_NAME_CHARLIST, *(++ptr)))
;
loc->l = pos;
loc->r = (size_t)(ptr - data) - 1;
return SUCCEED;
}