calendarspec.h revision 51ffa239e8920499a9b5f85b1d98068cf931cd14
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#pragma once
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering/***
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering This file is part of systemd.
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering Copyright 2012 Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering systemd is free software; you can redistribute it and/or modify it
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering under the terms of the GNU Lesser General Public License as published by
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering (at your option) any later version.
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering systemd is distributed in the hope that it will be useful, but
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering Lesser General Public License for more details.
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering You should have received a copy of the GNU Lesser General Public License
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering***/
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
11c3a36649e5e5e77db499c92f3cdcbd619efd3aThomas Hindoe Paaboel Andersen/* A structure for specifying (possibly repetitive) points in calendar
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering * time, a la cron */
11c3a36649e5e5e77db499c92f3cdcbd619efd3aThomas Hindoe Paaboel Andersen
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include <stdbool.h>
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering#include "util.h"
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringtypedef struct CalendarComponent {
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering int value;
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering int repeat;
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering struct CalendarComponent *next;
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering} CalendarComponent;
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poetteringtypedef struct CalendarSpec {
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering int weekdays_bits;
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering bool utc;
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering CalendarComponent *year;
b11d6a7bed4d867fb9f6ff4e7eb4ab20fcdc9301Lennart Poettering CalendarComponent *month;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering CalendarComponent *day;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering CalendarComponent *hour;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering CalendarComponent *minute;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering CalendarComponent *second;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering} CalendarSpec;
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringvoid calendar_spec_free(CalendarSpec *c);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringint calendar_spec_normalize(CalendarSpec *spec);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringbool calendar_spec_valid(CalendarSpec *spec);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringint calendar_spec_to_string(const CalendarSpec *spec, char **p);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringint calendar_spec_from_string(const char *p, CalendarSpec **spec);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poetteringint calendar_spec_next_usec(const CalendarSpec *spec, usec_t usec, usec_t *next);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering