Source
/*
** 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.
**/
extern zbx_mock_config_t mock_config;
void mock_config_free_user_macros(void);
static int config_gmacro_context_compare(const void *d1, const void *d2)
{
const ZBX_DC_GMACRO *m1 = *(const ZBX_DC_GMACRO **)d1;
const ZBX_DC_GMACRO *m2 = *(const ZBX_DC_GMACRO **)d2;
/* macros without context have higher priority than macros with */
if (NULL == m1->context)
return NULL == m2->context ? 0 : -1;
if (NULL == m2->context)
return 1;
/* CONDITION_OPERATOR_EQUAL (0) has higher priority than CONDITION_OPERATOR_REGEXP (8) */
ZBX_RETURN_IF_NOT_EQUAL(m1->context_op, m2->context_op);
return strcmp(m1->context, m2->context);
}
static int config_hmacro_context_compare(const void *d1, const void *d2)
{
const ZBX_DC_HMACRO *m1 = *(const ZBX_DC_HMACRO **)d1;
const ZBX_DC_HMACRO *m2 = *(const ZBX_DC_HMACRO **)d2;
/* macros without context have higher priority than macros with */
if (NULL == m1->context)