Source
int node_process_command(zbx_socket_t *sock, const char *data, const struct zbx_json_parse *jp, int config_timeout,
/*
** 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/>.
**/
/**********************************************************************************
* *
* Purpose: replaces occurrence of macro in input string with value given in *
* macrovalue, with memory management *
* *
* Parameters: in - [IN] input string to be processed *
* macro - [IN] macro to replace *
* macrovalue - [IN] value to replace macro with *
* out - [IN/OUT] pointer to memory holding result *
* out_alloc - [IN/OUT] size of memory holding result *
* *
* Return value: SUCCEED - remote command was executed successfully *
* FAIL - error occurred *
* *
**********************************************************************************/
static void substitute_macro(const char *in, const char *macro, const char *macrovalue, char **out,
size_t *out_alloc)
{
zbx_token_t token;
int pos = 0;
size_t out_offset = 0, macrovalue_len;
macrovalue_len = strlen(macrovalue);
zbx_strcpy_alloc(out, out_alloc, &out_offset, in);
out_offset++;