diff options
Diffstat (limited to 'src/action.c')
| -rw-r--r-- | src/action.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/action.c b/src/action.c index c8ccee1..2ceae9b 100644 --- a/src/action.c +++ b/src/action.c @@ -3,6 +3,7 @@ #include "action.h" #include "block.h" +#include "any_log.h" void action_perform(action_t *action, block_t *block, config_t *config) { @@ -13,9 +14,15 @@ void action_perform(action_t *action, block_t *block, config_t *config) if (strncmp(key, "block.", 6)) abort(); + int sep = 6; + while (key[sep] != '.' && key[sep] != '\0') sep++; + + if (key[sep] == '\0') abort(); + block_t *target = NULL; for (size_t i = 0; i < config->n_blocks; i++) { - if (!strcmp(key + 6, config->blocks[i]->label)) { + size_t length = strlen(config->blocks[i]->label); + if (length == (sep - 6) && !strncmp(key + 6, config->blocks[i]->label, length)) { target = config->blocks[i]; break; } @@ -24,8 +31,15 @@ void action_perform(action_t *action, block_t *block, config_t *config) if (target == NULL) abort(); + if (target->scheme->change_fn == NULL) { + log_warn("Block '%s' does not support changing values", target->label); + continue; + } + block_change(target, key, value); } + + log_debug("Performed action '%s'", action->label); } int action_validate(action_t *action, config_t *config) @@ -42,4 +56,5 @@ void action_free(action_t *action) } free(action->parts); + free(action->label); } |
