Source
static void dbpatch_add_function(const zbx_dbpatch_function_t *template, zbx_uint64_t functionid, const char *name,
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/* Function argument descriptors. */
/* Used in varargs list to describe following parameter mapping to old position. */
/* Terminated with ZBX_DBPATCH_ARG_NONE. */
/* For example: */
/* ..., ZBX_DBPATCH_ARG_NUM, 1, ZBX_DBPATCH_ARG_STR, 0, ZBX_DBPATCH_ARG_NONE) */
/* meaning first numeric parameter copied from second parameter */
/* second string parameter copied from first parameter */
typedef enum
{
ZBX_DBPATCH_ARG_NONE, /* terminating descriptor, must be put at the end of the list */
ZBX_DBPATCH_ARG_HIST, /* history period followed by sec/num (int) and timeshift (int) indexes */
ZBX_DBPATCH_ARG_TIME, /* time value followed by argument index (int) */
ZBX_DBPATCH_ARG_NUM, /* number value followed by argument index (int) */
ZBX_DBPATCH_ARG_STR, /* string value followed by argument index (int) */
ZBX_DBPATCH_ARG_TREND, /* trend period, followed by period (int) and timeshift (int) indexes */
ZBX_DBPATCH_ARG_CONST_STR, /* constant,fffffff followed by string (char *) value */
}
zbx_dbpatch_arg_t;
ZBX_VECTOR_IMPL(strloc, zbx_strloc_t)
/******************************************************************************
* *
* Purpose: rename macros in the string *
* *
* Parameters: in - [IN] the input string *
* oldmacro - [IN] the macro to rename *
* newmacro - [IN] the new macro name *
* out - [IN/OUT] the string with renamed macros *
* out_alloc - [IN/OUT] the output buffer size *
* *
* Return value: SUCCEED - macros were found and renamed *
* FAIL - no target macros were found *
* *
* Comments: If the oldmacro is found in input string then all occurrences of *
* it are replaced with the new macro in the output string. *
* Otherwise the output string is not changed. *
* *
******************************************************************************/
static int str_rename_macro(const char *in, const char *oldmacro, const char *newmacro, char **out,
size_t *out_alloc)
{
zbx_token_t token;