Source
/*
** 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/>.
**/
static ALIAS *aliasList = NULL;
void test_aliases(void)
{
ALIAS *alias;
for (alias = aliasList; NULL != alias; alias = alias->next)
zbx_test_parameter(alias->name);
}
void zbx_add_alias(const char *name, const char *value)
{
ALIAS *alias = NULL;
for (alias = aliasList; ; alias = alias->next)
{
/* add new Alias */
if (NULL == alias)
{
alias = (ALIAS *)zbx_malloc(alias, sizeof(ALIAS));
alias->name = strdup(name);
alias->value = strdup(value);
alias->next = aliasList;
aliasList = alias;
zabbix_log(LOG_LEVEL_DEBUG, "Alias added: \"%s\" -> \"%s\"", name, value);
break;
}
/* treat duplicate Alias as error */
if (0 == strcmp(alias->name, name))
{
zabbix_log(LOG_LEVEL_CRIT, "failed to add Alias \"%s\": duplicate name", name);
exit(EXIT_FAILURE);
}
}
}
void zbx_alias_list_free(void)
{
ALIAS *curr, *next;