projects
/
project
/
procd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add wildcard support to trigger matching code
[project/procd.git]
/
service
/
trigger.c
diff --git
a/service/trigger.c
b/service/trigger.c
index
9fb77cd
..
ced758b
100644
(file)
--- a/
service/trigger.c
+++ b/
service/trigger.c
@@
-323,6
+323,14
@@
void trigger_init(void)
q.max_running_tasks = 1;
}
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;
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;
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);
if (t->timeout) {
free(t->data);
t->data = blob_memdup(data);