]>
Commit | Line | Data |
---|---|---|
03467c88 | 1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
5cb5a6ff | 2 | |
c2f1db8f | 3 | #pragma once |
5cb5a6ff | 4 | |
a7334b09 LP |
5 | /*** |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2010 Lennart Poettering | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
5430f7f2 LP |
11 | under the terms of the GNU Lesser General Public License as published by |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
a7334b09 LP |
13 | (at your option) any later version. |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
5430f7f2 | 18 | Lesser General Public License for more details. |
a7334b09 | 19 | |
5430f7f2 | 20 | You should have received a copy of the GNU Lesser General Public License |
a7334b09 LP |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. |
22 | ***/ | |
23 | ||
5cb5a6ff LP |
24 | typedef struct Timer Timer; |
25 | ||
36697dc0 | 26 | #include "calendarspec.h" |
5cb5a6ff LP |
27 | |
28 | typedef enum TimerState { | |
29 | TIMER_DEAD, | |
30 | TIMER_WAITING, | |
31 | TIMER_RUNNING, | |
871d7de4 | 32 | TIMER_ELAPSED, |
fdf20a31 | 33 | TIMER_FAILED, |
871d7de4 LP |
34 | _TIMER_STATE_MAX, |
35 | _TIMER_STATE_INVALID = -1 | |
5cb5a6ff LP |
36 | } TimerState; |
37 | ||
871d7de4 LP |
38 | typedef enum TimerBase { |
39 | TIMER_ACTIVE, | |
40 | TIMER_BOOT, | |
41 | TIMER_STARTUP, | |
42 | TIMER_UNIT_ACTIVE, | |
43 | TIMER_UNIT_INACTIVE, | |
36697dc0 | 44 | TIMER_CALENDAR, |
871d7de4 LP |
45 | _TIMER_BASE_MAX, |
46 | _TIMER_BASE_INVALID = -1 | |
47 | } TimerBase; | |
48 | ||
49 | typedef struct TimerValue { | |
36697dc0 LP |
50 | TimerBase base; |
51 | bool disabled; | |
36697dc0 | 52 | |
b719810d LP |
53 | usec_t value; /* only for monotonic events */ |
54 | CalendarSpec *calendar_spec; /* only for calendar events */ | |
871d7de4 LP |
55 | usec_t next_elapse; |
56 | ||
871d7de4 LP |
57 | LIST_FIELDS(struct TimerValue, value); |
58 | } TimerValue; | |
59 | ||
067d72c9 LP |
60 | typedef enum TimerResult { |
61 | TIMER_SUCCESS, | |
62 | TIMER_FAILURE_RESOURCES, | |
63 | _TIMER_RESULT_MAX, | |
64 | _TIMER_RESULT_INVALID = -1 | |
65 | } TimerResult; | |
66 | ||
5cb5a6ff | 67 | struct Timer { |
ac155bb8 | 68 | Unit meta; |
5cb5a6ff | 69 | |
9f5eb56a LP |
70 | usec_t accuracy_usec; |
71 | ||
871d7de4 | 72 | LIST_HEAD(TimerValue, values); |
36697dc0 | 73 | usec_t next_elapse_realtime; |
dedabea4 LP |
74 | usec_t next_elapse_monotonic_or_boottime; |
75 | dual_timestamp last_trigger; | |
5cb5a6ff | 76 | |
01f78473 | 77 | TimerState state, deserialized_state; |
871d7de4 | 78 | |
718db961 LP |
79 | sd_event_source *monotonic_event_source; |
80 | sd_event_source *realtime_event_source; | |
871d7de4 | 81 | |
067d72c9 | 82 | TimerResult result; |
e41e1943 | 83 | |
06642d17 | 84 | bool persistent; |
dedabea4 | 85 | bool wake_system; |
06642d17 LP |
86 | |
87 | char *stamp_path; | |
5cb5a6ff LP |
88 | }; |
89 | ||
74051b9b LP |
90 | void timer_free_values(Timer *t); |
91 | ||
47be870b | 92 | extern const UnitVTable timer_vtable; |
5cb5a6ff | 93 | |
44a6b1b6 ZJS |
94 | const char *timer_state_to_string(TimerState i) _const_; |
95 | TimerState timer_state_from_string(const char *s) _pure_; | |
871d7de4 | 96 | |
44a6b1b6 ZJS |
97 | const char *timer_base_to_string(TimerBase i) _const_; |
98 | TimerBase timer_base_from_string(const char *s) _pure_; | |
871d7de4 | 99 | |
44a6b1b6 ZJS |
100 | const char* timer_result_to_string(TimerResult i) _const_; |
101 | TimerResult timer_result_from_string(const char *s) _pure_; |