src/graph.[ch]: Implement "graph_matches_ident".
[collection4.git] / src / graph.c
index d3a8d6f..75c83b1 100644 (file)
@@ -297,7 +297,7 @@ int graph_add_def (graph_config_t *cfg, graph_def_t *def) /* {{{ */
   return (def_append (cfg->defs, tmp));
 } /* }}} int graph_add_def */
 
-_Bool graph_matches_ident (graph_config_t *cfg, const graph_ident_t *ident) /* {{{ */
+_Bool graph_ident_matches (graph_config_t *cfg, const graph_ident_t *ident) /* {{{ */
 {
 #if C4_DEBUG
   if ((cfg == NULL) || (ident == NULL))
@@ -305,6 +305,17 @@ _Bool graph_matches_ident (graph_config_t *cfg, const graph_ident_t *ident) /* {
 #endif
 
   return (ident_matches (cfg->select, ident));
+} /* }}} _Bool graph_ident_matches */
+
+_Bool graph_matches_ident (graph_config_t *cfg, /* {{{ */
+    const graph_ident_t *selector)
+{
+#if C4_DEBUG
+  if ((cfg == NULL) || (selector == NULL))
+    return (0);
+#endif
+
+  return (ident_matches (selector, cfg->select));
 } /* }}} _Bool graph_matches_ident */
 
 _Bool graph_matches_field (graph_config_t *cfg, /* {{{ */
@@ -486,10 +497,18 @@ int graph_compare (graph_config_t *cfg, const graph_ident_t *ident) /* {{{ */
 
 static int graph_sort_instances_cb (const void *v0, const void *v1) /* {{{ */
 {
-  return (ident_compare (*(graph_ident_t * const *) v0,
-        *(graph_ident_t * const *) v1));
+  return (inst_compare (*(graph_instance_t * const *) v0,
+        *(graph_instance_t * const *) v1));
 } /* }}} int graph_sort_instances_cb */
 
+size_t graph_num_instances (graph_config_t *cfg) /* {{{ */
+{
+  if (cfg == NULL)
+    return ((size_t) -1);
+
+  return (cfg->instances_num);
+} /* }}} size_t graph_num_instances */
+
 int graph_sort_instances (graph_config_t *cfg) /* {{{ */
 {
   if (cfg == NULL)