Source
static void resolve_opdata(const zbx_db_event *event, char **replace_to, const char *tz, char *error, int maxerrlen)
/*
** 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: formats full user name from name, surname and alias. *
* *
* Parameters: name - [IN] user name, can be empty string *
* surname - [IN] user surname, can be empty string *
* alias - [IN] user alias *
* *
* Return value: the formatted user fullname. *
* *
******************************************************************************/
static char *format_user_fullname(const char *name, const char *surname, const char *alias)
{
char *buf = NULL;
size_t buf_alloc = 0, buf_offset = 0;
zbx_strcpy_alloc(&buf, &buf_alloc, &buf_offset, name);
if ('\0' != *surname)
{
if (0 != buf_offset)
zbx_chrcpy_alloc(&buf, &buf_alloc, &buf_offset, ' ');
zbx_strcpy_alloc(&buf, &buf_alloc, &buf_offset, surname);
}
if ('\0' != *alias)
{
size_t offset = buf_offset;
if (0 != buf_offset)
zbx_strcpy_alloc(&buf, &buf_alloc, &buf_offset, " (");
zbx_strcpy_alloc(&buf, &buf_alloc, &buf_offset, alias);
if (0 != offset)
zbx_chrcpy_alloc(&buf, &buf_alloc, &buf_offset, ')');
}
return buf;
}
/* macros that are supported in expression macro */
static const char *expr_macros[] = {MVAR_HOST_HOST, MVAR_HOSTNAME, MVAR_ITEM_KEY, NULL};
/******************************************************************************
* *
* Purpose: request recovery event value by macro. *
* *
******************************************************************************/
static void get_recovery_event_value(const char *macro, const zbx_db_event *r_event, char **replace_to,
const char *tz)
{
if (0 == strcmp(macro, MVAR_EVENT_RECOVERY_DATE))
{
*replace_to = zbx_strdup(*replace_to, zbx_date2str(r_event->clock, tz));