Source
zbx_export_file_t *zbx_problems_export_init(zbx_get_export_file_f get_export_file_cb, const char *process_name,
/*
** Copyright (C) 2001-2024 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 zbx_get_export_file_f get_history_file;
static zbx_get_export_file_f get_trends_file;
static zbx_get_export_file_f get_problems_file;
static zbx_config_export_t *config_export;
/******************************************************************************
* *
* Purpose: validate export type *
* *
* Parameters: export_type - [in] list of export types *
* export_mask - [out] export types mask (if SUCCEED) *
* *
* Return value: SUCCEED - valid configuration *
* FAIL - otherwise *
* *
******************************************************************************/
int zbx_validate_export_type(char *export_type, uint32_t *export_mask)
{
int ret = SUCCEED;
char *start = export_type;
uint32_t mask;
char *types[] = {
ZBX_OPTION_EXPTYPE_EVENTS,
ZBX_OPTION_EXPTYPE_HISTORY,
ZBX_OPTION_EXPTYPE_TRENDS,
NULL};
size_t lengths[] = {
ZBX_CONST_STRLEN(ZBX_OPTION_EXPTYPE_EVENTS),
ZBX_CONST_STRLEN(ZBX_OPTION_EXPTYPE_HISTORY),
ZBX_CONST_STRLEN(ZBX_OPTION_EXPTYPE_TRENDS),
0};
if (NULL != start)
{
mask = 0;
do
{
int i;
char *end;
end = strchr(start, ',');
for (i = 0; NULL != types[i]; i++)
{
if ((NULL != end && lengths[i] == (size_t)(end - start) &&
0 == strncmp(start, types[i], lengths[i])) ||
(NULL == end && 0 == strcmp(start, types[i])))
{
mask |= (uint32_t)(1 << i);
break;
}
}
if (NULL == types[i])
{
ret = FAIL;
break;
}
start = end;
} while (NULL != start++);
}
else
mask = ZBX_FLAG_EXPTYPE_EVENTS | ZBX_FLAG_EXPTYPE_HISTORY | ZBX_FLAG_EXPTYPE_TRENDS;
if (NULL != export_mask)