zabbix-agent2/src/libs/zbxdbcache/dbconfig.c
/******************************************************************************
 *                                                                            *
 * Function: dc_expand_user_macros_in_func_params                             *
 *                                                                            *
 * Purpose: expand user macros in trigger function parameters                 *
 *                                                                            *
 * Parameters: params - [IN] the function parameters                          *
 *             hostid - [IN] host of the item used in function                *
 *                                                                            *
 * Return value: The function parameters with expanded user macros.           *
 *                                                                            *
 ******************************************************************************/
dc_expand_user_macros_in_func_params

Purpose: expand user macros in trigger function parameters

Parameters: params - [IN] the function parameters
hostid - [IN] host of the item used in function

Return value: The function parameters with expanded user macros.
dc_expand_user_macros_in_func_params Purpose : expand user macros in trigger function parameters Parameters : params - [ IN ] the function parameters hostid - [ IN ] host of the item used in function Return value : The function parameters with expanded user macros .
char	*dc_expand_user_macros_in_func_params(const char *params, zbx_uint64_t hostid)
{
	const char	*ptr;
	size_t		params_len;
	char		*buf;
	size_t		buf_alloc, buf_offset = 0, sep_pos;
	if ('\0' == *params)
		return zbx_strdup(NULL, params);
	buf_alloc = params_len = strlen(params);
	buf = zbx_malloc(NULL, buf_alloc);
	for (ptr = params; ptr < params + params_len; ptr += sep_pos + 1)
	{
		size_t	param_pos, param_len;
		int	quoted;
		char	*param, *resolved_param;
		zbx_function_param_parse(ptr, &param_pos, &param_len, &sep_pos);
		param = zbx_function_param_unquote_dyn(ptr + param_pos, param_len, &quoted);
		resolved_param = dc_expand_user_macros(param, &hostid, 1);
		if (SUCCEED == zbx_function_param_quote(&resolved_param, quoted))
			zbx_strcpy_alloc(&buf, &buf_alloc, &buf_offset, resolved_param);
		else
			zbx_strncpy_alloc(&buf, &buf_alloc, &buf_offset, ptr + param_pos, param_len);
		if (',' == ptr[sep_pos])
			zbx_chrcpy_alloc(&buf, &buf_alloc, &buf_offset, ',');
		zbx_free(resolved_param);
		zbx_free(param);
	}
	return buf;
}
char * dc_expand_user_macros_in_func_params ( const char * params , zbx_uint64_t hostid ) { const char * ptr ; size_t params_len ; char * buf ; size_t buf_alloc , buf_offset = 0 , sep_pos ; if ( ' \0 ' == * params ) return zbx_strdup ( NULL , params ) ; buf_alloc = params_len = strlen ( params ) ; buf = zbx_malloc ( NULL , buf_alloc ) ; for ( ptr = params ; ptr < params + params_len ; ptr += sep_pos + 1 ) { size_t param_pos , param_len ; int quoted ; char * param , * resolved_param ; zbx_function_param_parse ( ptr , & param_pos , & param_len , & sep_pos ) ; param = zbx_function_param_unquote_dyn ( ptr + param_pos , param_len , & quoted ) ; resolved_param = dc_expand_user_macros ( param , & hostid , 1 ) ; if ( SUCCEED == zbx_function_param_quote ( & resolved_param , quoted ) ) zbx_strcpy_alloc ( & buf , & buf_alloc , & buf_offset , resolved_param ) ; else zbx_strncpy_alloc ( & buf , & buf_alloc , & buf_offset , ptr + param_pos , param_len ) ; if ( ' ' == ptr [ sep_pos ] ) zbx_chrcpy_alloc ( & buf , & buf_alloc , & buf_offset , ' ' ) ; zbx_free ( resolved_param ) ; zbx_free ( param ) ; } return buf ; }
Function: dc_expand_user_macros_in_func_params                             
                                                                            
 Purpose: expand user macros in trigger function parameters                 
                                                                            
 Parameters: params - [IN] the function parameters                          
             hostid - [IN] host of the item used in function                
                                                                            
 Return value: The function parameters with expanded user macros.
Function : dc_expand_user_macros_in_func_params Purpose : expand user macros in trigger function parameters Parameters : params - [ IN ] the function parameters hostid - [ IN ] host of the item used in function Return value : The function parameters with expanded user macros .