Source
zbx_export_file_t *zbx_problems_export_init(zbx_get_export_file_f get_export_file_cb, const char *process_name,
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
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;