diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-21 14:33:15 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-06-24 12:52:50 +0800 |
commit | 9933fe75fd5f7f6a281a67deb3a8d919f5617f89 (patch) | |
tree | c558baee28010e1f0dba06c86eb30c31367a306a | |
parent | 78c82fbd0a481249de1763b5d43bb9876ea612bd (diff) | |
download | talos-petitboot-9933fe75fd5f7f6a281a67deb3a8d919f5617f89.tar.gz talos-petitboot-9933fe75fd5f7f6a281a67deb3a8d919f5617f89.zip |
discover/event: Allow empty param values
Useful for specifying defaults:
pb-event add@defaults name='Netboot' \
image=http://192.168.0.1/vmlinuz \
default
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | discover/event.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/discover/event.c b/discover/event.c index 7cb128f..cced658 100644 --- a/discover/event.c +++ b/discover/event.c @@ -80,21 +80,23 @@ static void event_parse_params(struct event *event, const char *buf, int len) continue; } - /* find the separator */ - sep = memchr(buf, '=', param_len); - if (!sep) - continue; - - name_len = sep - buf; - value_len = param_len - name_len - 1; - /* update the params array */ event->params = talloc_realloc(event, event->params, struct param, ++event->n_params); param = &event->params[event->n_params - 1]; + sep = memchr(buf, '=', param_len); + if (!sep) { + name_len = param_len; + value_len = 0; + param->value = ""; + } else { + name_len = sep - buf; + value_len = param_len - name_len - 1; + param->value = talloc_strndup(event, sep + 1, + value_len); + } param->name = talloc_strndup(event, buf, name_len); - param->value = talloc_strndup(event, sep + 1, value_len); } } |