diff --git a/server/src/cfg.c b/server/src/cfg.c index acfb915b2..eaf7f7a34 100644 --- a/server/src/cfg.c +++ b/server/src/cfg.c @@ -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); diff --git a/server/src/path.c b/server/src/path.c index 8e31b78af..031b1383c 100644 --- a/server/src/path.c +++ b/server/src/path.c @@ -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; }