1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

allow paths without destination nodes (hooks are executed..)

This commit is contained in:
Steffen Vogel 2015-10-13 15:40:34 +02:00
parent 41cd1402be
commit b26a92165d
2 changed files with 11 additions and 20 deletions

View file

@ -101,34 +101,29 @@ int config_parse_global(config_setting_t *cfg, struct settings *set)
int config_parse_path(config_setting_t *cfg,
struct list *paths, struct list *nodes, struct settings *set)
{
config_setting_t *cfg_in, *cfg_out, *cfg_hook;
const char *in;
int enabled;
int reverse;
int enabled, reverse;
struct path *p = path_create();
/* Input node */
config_setting_t *cfg_in = config_setting_get_member(cfg, "in");
if (!cfg_in || config_setting_type(cfg_in) != CONFIG_TYPE_STRING)
cerror(cfg, "Invalid input node for path");
if (!config_setting_lookup_string(cfg, "in", &in))
cerror(cfg, "Missing input node for path");
in = config_setting_get_string(cfg_in);
p->in = list_lookup(nodes, in);
if (!p->in)
cerror(cfg_in, "Invalid input node '%s'", in);
/* Output node(s) */
config_setting_t *cfg_out = config_setting_get_member(cfg, "out");
cfg_out = config_setting_get_member(cfg, "out");
if (cfg_out)
config_parse_nodelist(cfg_out, &p->destinations, nodes);
if (list_length(&p->destinations) < 1)
cerror(cfg, "Missing output node for path");
p->out = (struct node *) list_first(&p->destinations);
/* Optional settings */
config_setting_t *cfg_hook = config_setting_get_member(cfg, "hook");
cfg_hook = config_setting_get_member(cfg, "hook");
if (cfg_hook)
config_parse_hooklist(cfg_hook, &p->hooks);

View file

@ -193,16 +193,12 @@ char * path_print(struct path *p)
{
char *buf = alloc(32);
strcatf(&buf, "%s " MAG("=>"), p->in->name);
strcatf(&buf, "%s " MAG("=>") " [", p->in->name);
if (list_length(&p->destinations) > 1) {
strcatf(&buf, " [");
list_foreach(struct node *n, &p->destinations)
strcatf(&buf, " %s", n->name);
strcatf(&buf, " ]");
}
else
strcatf(&buf, " %s", p->out->name);
list_foreach(struct node *n, &p->destinations)
strcatf(&buf, " %s", n->name);
strcatf(&buf, " ]");
return buf;
}