Source
int zbx_eval_get_group_filter(zbx_eval_context_t *ctx, zbx_vector_str_t *groups, char **filter, char **error)
/*
** 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.
**/
/* The tag expression token is virtual token used during item query filter processing. */
/******************************************************************************
* *
* Purpose: parse item query /host/key?[filter] into host, key and filter *
* components *
* *
* Parameters: str - [IN] the item query *
* len - [IN] the query length *
* query - [IN] the parsed item query *
* *
* Return value: The number of parsed characters. *
* *
******************************************************************************/
size_t zbx_eval_parse_query(const char *str, size_t len, zbx_item_query_t *query)
{
size_t n;
const char *host, *key, *filter;
if (0 == (n = eval_parse_query(str, &host, &key, &filter)) || n != len)
return 0;
query->host = (host != key - 1 ? zbx_substr(host, 0, key - host - 2) : NULL);
if (NULL != filter)
{
query->key = zbx_substr(key, 0, (filter - key) - 3);
query->filter = zbx_substr(filter, 0, (str + len - filter) - 2);
}
else
{
query->key = zbx_substr(key, 0, (str + len - key) - 1);
query->filter = NULL;
}
return n;
}