return (NULL);
for (i = 0; i < cfg->instances_num; i++)
- if (inst_matches_ident (cfg->instances[i], ident))
+ if (inst_ident_matches (cfg->instances[i], ident))
return (cfg->instances[i]);
return (NULL);
_Bool ident_matches (const graph_ident_t *selector, /* {{{ */
const graph_ident_t *ident)
{
- if ((selector == NULL) && (ident == NULL))
+ if ((selector == NULL) || (ident == NULL))
return (0);
- else if (selector == NULL)
- return (-1);
- else if (ident == NULL)
- return (1);
if (!part_matches (selector->host, ident->host))
return (0);
return (ident_compare (inst->select, ident));
} /* }}} int inst_compare_ident */
-_Bool inst_matches_ident (graph_instance_t *inst, /* {{{ */
+_Bool inst_ident_matches (graph_instance_t *inst, /* {{{ */
const graph_ident_t *ident)
{
if ((inst == NULL) || (ident == NULL))
return (0);
return (ident_matches (inst->select, ident));
+} /* }}} _Bool inst_ident_matches */
+
+_Bool inst_matches_ident (graph_instance_t *inst, /* {{{ */
+ const graph_ident_t *ident)
+{
+ if ((inst == NULL) || (ident == NULL))
+ return (0);
+
+ return (ident_matches (ident, inst->select));
} /* }}} _Bool inst_matches_ident */
_Bool inst_matches_string (graph_config_t *cfg, /* {{{ */
int inst_compare_ident (graph_instance_t *inst, const graph_ident_t *ident);
-_Bool inst_matches_ident (graph_instance_t *inst, const graph_ident_t *ident);
+/* Returns true if "ident" matches the instance's selector. */
+_Bool inst_ident_matches (graph_instance_t *inst, const graph_ident_t *ident);
+
+/* Returns true if the instance's selector matches the (more general)
+ * "selector" ident. */
+_Bool inst_matches_ident (graph_instance_t *inst,
+ const graph_ident_t *selector);
_Bool inst_matches_string (graph_config_t *cfg, graph_instance_t *inst,
const char *term);