Source
xxxxxxxxxx
/*
** 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 rtc_parse_scope(const char *str, int *scope)
{
if (0 == strcmp(str, "rwlock"))
*scope = ZBX_PROF_RWLOCK;
else if (0 == strcmp(str, "mutex"))
*scope = ZBX_PROF_MUTEX;
else if (0 == strcmp(str, "processing"))
*scope = ZBX_PROF_PROCESSING;
else
return FAIL;
return SUCCEED;
}
/******************************************************************************
* *
* Purpose: get rtc option parameter *
* *
* Parameters: opt - [IN] runtime control option parameter *
* size - [OUT] number of parsed bytes *
* error - [OUT] error message *
* *
* Return value: SUCCEED - parameter was found or not specified *
* FAIL - otherwise *
* *
******************************************************************************/
int rtc_option_get_parameter(const char *param, size_t *size, char **error)
{
switch (*param)
{
case '\0':
*size = 0;
return SUCCEED;
case '=':
/* check for empty parameter */
if ('\0' == param[1])
break;
*size = 1;
return SUCCEED;
}
*error = zbx_dsprintf(*error, "unspecified process identifier or type: \"%s\"", param);
return FAIL;
}
/******************************************************************************
* *
* Purpose: get unsigned value from parameter *
* *
* Parameters: param - [IN] runtime control option parameter *
* size - [OUT] number of parsed bytes *
* value - [OUT] parsed value *
* error - [OUT] error message *
* *
* Return value: SUCCEED - value was parsed or not specified *
* FAIL - otherwise *
* *
******************************************************************************/
static int rtc_option_get_ui64(const char *param, size_t *size, zbx_uint64_t *value)
{
const char *ptr = param;
while (0 != isdigit(*ptr))
ptr++;
if (ptr != param)
{
if (FAIL == zbx_is_uint64_n(param, (size_t)(ptr - param), value))
return FAIL;