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 int parse_log_level_options(const char *opt, size_t len, unsigned int *scope, unsigned int *data)
{
unsigned short num = 0;
const char *rtc_options;
rtc_options = opt + len;
if ('\0' == *rtc_options)
{
*scope = ZBX_RTC_LOG_SCOPE_FLAG | ZBX_RTC_LOG_SCOPE_PID;
*data = 0;
}
else if ('=' != *rtc_options)
{
zbx_error("invalid runtime control option: %s", opt);
return FAIL;
}
else if (0 != isdigit(*(++rtc_options)))
{
/* convert PID */
if (FAIL == zbx_is_ushort(rtc_options, &num) || 0 == num)
{
zbx_error("invalid log level control target: invalid or unsupported process identifier");
return FAIL;
}
*scope = ZBX_RTC_LOG_SCOPE_FLAG | ZBX_RTC_LOG_SCOPE_PID;
*data = num;
}
else
{
char *proc_name = NULL, *proc_num;
int proc_type;
if ('\0' == *rtc_options)
{
zbx_error("invalid log level control target: unspecified process identifier or type");
return FAIL;
}
proc_name = zbx_strdup(proc_name, rtc_options);
if (NULL != (proc_num = strchr(proc_name, ',')))