| 1 |
/* SPDX-License-Identifier: LGPL-2.1-or-later */ |
| 2 |
#pragma once |
| 3 |
|
| 4 |
/* A structure for specifying (possibly repetitive) points in calendar |
| 5 |
* time, a la cron */ |
| 6 |
|
| 7 |
#include "shared-forward.h" |
| 8 |
|
| 9 |
typedef struct CalendarComponent { |
| 10 |
int start; |
| 11 |
int stop; |
| 12 |
int repeat; |
| 13 |
|
| 14 |
struct CalendarComponent *next; |
| 15 |
} CalendarComponent; |
| 16 |
|
| 17 |
typedef struct CalendarSpec { |
| 18 |
int weekdays_bits; |
| 19 |
bool end_of_month:1; |
| 20 |
bool utc:1; |
| 21 |
signed int dst:2; |
| 22 |
char *timezone; |
| 23 |
|
| 24 |
CalendarComponent *year; |
| 25 |
CalendarComponent *month; |
| 26 |
CalendarComponent *day; |
| 27 |
|
| 28 |
CalendarComponent *hour; |
| 29 |
CalendarComponent *minute; |
| 30 |
CalendarComponent *microsecond; |
| 31 |
} CalendarSpec; |
| 32 |
|
| 33 |
CalendarSpec* calendar_spec_free(CalendarSpec *c); |
| 34 |
|
| 35 |
bool calendar_spec_valid(CalendarSpec *spec); |
| 36 |
|
| 37 |
int calendar_spec_to_string(const CalendarSpec *spec, char **ret); |
| 38 |
int calendar_spec_from_string(const char *p, CalendarSpec **ret); |
| 39 |
|
| 40 |
int calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next); |
| 41 |
|
| 42 |
DEFINE_TRIVIAL_CLEANUP_FUNC(CalendarSpec*, calendar_spec_free); |