diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-01-23 01:52:57 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-01-23 01:52:57 +0100 |
commit | 5cb5a6ffc33667c93e9bc3572534dcaa684046e3 (patch) | |
tree | 51e8b6260d56027c4d610ff6db5882737101a809 /timer.c | |
parent | cd2dbd7df9f1b8c46386b2898523aec3dd4578fd (diff) |
first attempt in implementinging execution logic
Diffstat (limited to 'timer.c')
-rw-r--r-- | timer.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/timer.c b/timer.c new file mode 100644 index 0000000000..b1571ce7ea --- /dev/null +++ b/timer.c @@ -0,0 +1,39 @@ +/*-*- Mode: C; c-basic-offset: 8 -*-*/ + +#include "name.h" +#include "timer.h" + +static NameActiveState timer_active_state(Name *n) { + + static const NameActiveState table[_TIMER_STATE_MAX] = { + [TIMER_DEAD] = NAME_INACTIVE, + [TIMER_WAITING] = NAME_ACTIVE, + [TIMER_RUNNING] = NAME_ACTIVE + }; + + return table[TIMER(n)->state]; +} + +static void timer_free_hook(Name *n) { + Timer *t = TIMER(n); + + assert(t); + + if (t->service) + t->service->timer = NULL; +} + +const NameVTable timer_vtable = { + .suffix = ".timer", + + .load = name_load_fragment_and_dropin, + .dump = NULL, + + .start = NULL, + .stop = NULL, + .reload = NULL, + + .active_state = timer_active_state, + + .free_hook = timer_free_hook +}; |