Source
static int get_next_delay_interval(const zbx_flexible_interval_t *flex_intervals, time_t now, time_t *next_interval)
/*
** 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.
**/
typedef struct
{
int start_day; /* day of week when period starts */
int end_day; /* day of week when period ends, included */
int start_time; /* number of seconds from the beginning of the day when period starts */
int end_time; /* number of seconds from the beginning of the day when period ends, not included */
}
zbx_time_period_t;
typedef struct zbx_scheduler_filter
{
int start;
int end;
int step;
struct zbx_scheduler_filter *next;
}
zbx_scheduler_filter_t;
typedef struct zbx_scheduler_interval
{
zbx_scheduler_filter_t *mdays;
zbx_scheduler_filter_t *wdays;
zbx_scheduler_filter_t *hours;
zbx_scheduler_filter_t *minutes;
zbx_scheduler_filter_t *seconds;
int filter_level;
struct zbx_scheduler_interval *next;
}
zbx_scheduler_interval_t;
typedef struct zbx_flexible_interval
{
zbx_time_period_t period;
int delay;
struct zbx_flexible_interval *next;
}
zbx_flexible_interval_t;
struct zbx_custom_interval
{
zbx_flexible_interval_t *flexible;
zbx_scheduler_interval_t *scheduling;
};
/******************************************************************************
* *
* Purpose: check if current time is within given period *
* *
* Parameters: period - [IN] preprocessed time period *
* tm - [IN] broken-down time for comparison *
* *
* Return value: FAIL - out of period, SUCCEED - within the period *
* *
******************************************************************************/
static int check_time_period(const zbx_time_period_t period, struct tm *tm)
{
int day, time;