diff options
author | John Crispin <blogic@openwrt.org> | 2014-06-04 20:36:03 +0200 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2014-06-05 12:45:15 +0200 |
commit | 386dfd4cdb444633861a812c645d56bd5c329c78 (patch) | |
tree | ee968bdf2475ada19d09998b27c3862579389186 /service/trigger.c | |
parent | 0467aebb79f64d1c9d05a84367fda7c02c4ea6b8 (diff) | |
download | unitd-386dfd4cdb444633861a812c645d56bd5c329c78.tar unitd-386dfd4cdb444633861a812c645d56bd5c329c78.zip |
add wildcard support to trigger matching code
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'service/trigger.c')
-rw-r--r-- | service/trigger.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/service/trigger.c b/service/trigger.c index 9fb77cd..ced758b 100644 --- a/service/trigger.c +++ b/service/trigger.c @@ -323,6 +323,14 @@ void trigger_init(void) q.max_running_tasks = 1; } +static int trigger_match(const char *event, const char *match) +{ + char *wildcard = strstr(match, ".*"); + if (wildcard) + return strncmp(event, match, wildcard - match); + return strcmp(event, match); +} + void trigger_event(const char *type, struct blob_attr *data) { struct trigger *t; @@ -330,7 +338,7 @@ void trigger_event(const char *type, struct blob_attr *data) list_for_each_entry(t, &triggers, list) { if (t->pending || t->remove) continue; - if (!strcmp(t->type, type)) { + if (!trigger_match(type, t->type)) { if (t->timeout) { free(t->data); t->data = blob_memdup(data); |