]> git.ipfire.org Git - thirdparty/systemd.git/blob - timer.c
rework config file load logic
[thirdparty/systemd.git] / timer.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #include <errno.h>
4
5 #include "unit.h"
6 #include "timer.h"
7
8 static void timer_done(Unit *u) {
9 Timer *t = TIMER(u);
10
11 assert(t);
12 }
13
14 static int timer_init(Unit *u) {
15 int r;
16
17 assert(u);
18
19 /* Make sure this config file actually exists */
20
21 if ((r = unit_load_fragment_and_dropin(u)) <= 0)
22 return r < 0 ? r : -ENOENT;
23
24 return 0;
25 }
26
27 static UnitActiveState timer_active_state(Unit *u) {
28
29 static const UnitActiveState table[_TIMER_STATE_MAX] = {
30 [TIMER_DEAD] = UNIT_INACTIVE,
31 [TIMER_WAITING] = UNIT_ACTIVE,
32 [TIMER_RUNNING] = UNIT_ACTIVE
33 };
34
35 return table[TIMER(u)->state];
36 }
37
38 const UnitVTable timer_vtable = {
39 .suffix = ".timer",
40
41 .init = timer_init,
42 .done = timer_done,
43
44 .active_state = timer_active_state
45 };