Skip to content

Commit

Permalink
init: Allow wildcards in property triggers by using * for property value
Browse files Browse the repository at this point in the history
For example, the following trigger will fire when the sys.foo property
is set to any value:

on property:sys.foo=*
    write /data/foo hello

It is also possible to refer to the property within the trigger actions:

on property:sys.foo=*
    write /data/foo $sys.foo

Change-Id: If78d20a532f77e17aa5703d53be581ad6736cbcf
Signed-off-by: Mike Lockwood <lockwood@android.com>
  • Loading branch information
mikeandroid committed Jun 9, 2011
1 parent 2c4d5dc commit 7ba61b1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions init/init_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ void queue_property_triggers(const char *name, const char *value)

if (!strncmp(name, test, name_length) &&
test[name_length] == '=' &&
!strcmp(test + name_length + 1, value)) {
(!strcmp(test + name_length + 1, value) ||
!strcmp(test + name_length + 1, "*"))) {
action_add_queue_tail(act);
}
}
Expand Down Expand Up @@ -377,7 +378,8 @@ void queue_all_property_triggers()

/* does the property exist, and match the trigger value? */
value = property_get(prop_name);
if (value && !strcmp(equals + 1, value)) {
if (value && (!strcmp(equals + 1, value) ||
!strcmp(equals + 1, "*"))) {
action_add_queue_tail(act);
}
}
Expand Down

0 comments on commit 7ba61b1

Please sign in to comment.