chiark / gitweb /
implement proper binding on ports
[elogind.git] / timer.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 #include "name.h"
4 #include "timer.h"
5
6 static NameActiveState timer_active_state(Name *n) {
7
8         static const NameActiveState table[_TIMER_STATE_MAX] = {
9                 [TIMER_DEAD] = NAME_INACTIVE,
10                 [TIMER_WAITING] = NAME_ACTIVE,
11                 [TIMER_RUNNING] = NAME_ACTIVE
12         };
13
14         return table[TIMER(n)->state];
15 }
16
17 static void timer_free_hook(Name *n) {
18         Timer *t = TIMER(n);
19
20         assert(t);
21
22         if (t->service)
23                 t->service->timer = NULL;
24 }
25
26 const NameVTable timer_vtable = {
27         .suffix = ".timer",
28
29         .load = name_load_fragment_and_dropin,
30         .dump = NULL,
31
32         .start = NULL,
33         .stop = NULL,
34         .reload = NULL,
35
36         .active_state = timer_active_state,
37
38         .free_hook = timer_free_hook
39 };