Source
int zbx_calculate_macro_function(const char *expression, const zbx_token_func_macro_t *func_macro, char **out)
/*
** 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.
**/
/******************************************************************************
* *
* Purpose: calculates regular expression substitution *
* *
* Parameters: params - [IN] the function parameters *
* nparam - [IN] the function parameter count *
* out - [IN/OUT] the input/output value *
* *
* Return value: SUCCEED - the function was calculated successfully. *
* FAIL - the function calculation failed. *
* *
******************************************************************************/
static int macrofunc_regsub(char **params, size_t nparam, char **out)
{
char *value = NULL;
if (2 != nparam)
return FAIL;
if (FAIL == zbx_regexp_sub(*out, params[0], params[1], &value))
return FAIL;
if (NULL == value)
value = zbx_strdup(NULL, "");
zbx_free(*out);
*out = value;
return SUCCEED;
}
/******************************************************************************
* *
* Purpose: calculates case insensitive regular expression substitution *
* *