+#if C4_DEBUG
+ if ((cfg == NULL) || (selector == NULL))
+ return (0);
+#endif
+
+ return (ident_matches (selector, cfg->select));
+} /* }}} _Bool graph_matches_ident */
+
+_Bool graph_ident_intersect (graph_config_t *cfg, /* {{{ */
+ const graph_ident_t *selector)
+{
+#if C4_DEBUG
+ if ((cfg == NULL) || (selector == NULL))
+ return (0);
+#endif
+
+ return (ident_intersect (cfg->select, selector));
+} /* }}} _Bool graph_ident_intersect */
+
+_Bool graph_matches_field (graph_config_t *cfg, /* {{{ */
+ graph_ident_field_t field, const char *field_value)
+{
+ const char *selector_value;
+
+ if ((cfg == NULL) || (field_value == NULL))
+ return (0);
+
+ selector_value = ident_get_field (cfg->select, field);
+ if (selector_value == NULL)
+ return (0);
+
+ if (IS_ALL (selector_value) || IS_ANY (selector_value))
+ return (1);
+ else if (strcasecmp (selector_value, field_value) == 0)
+ return (1);
+
+ return (0);
+} /* }}} _Bool graph_matches_field */
+
+int graph_inst_foreach (graph_config_t *cfg, /* {{{ */
+ inst_callback_t cb, void *user_data)
+{
+ size_t i;
+ int status;
+
+ for (i = 0; i < cfg->instances_num; i++)
+ {
+ status = (*cb) (cfg->instances[i], user_data);
+ if (status != 0)
+ return (status);
+ }
+
+ return (0);
+} /* }}} int graph_inst_foreach */
+
+graph_instance_t *graph_inst_find_exact (graph_config_t *cfg, /* {{{ */
+ graph_ident_t *ident)
+{
+ size_t i;
+
+ if ((cfg == NULL) || (ident == NULL))
+ return (NULL);
+
+ for (i = 0; i < cfg->instances_num; i++)
+ if (inst_compare_ident (cfg->instances[i], ident) == 0)
+ return (cfg->instances[i]);
+
+ return (NULL);
+} /* }}} graph_instance_t *graph_inst_find_exact */
+
+graph_instance_t *graph_inst_find_matching (graph_config_t *cfg, /* {{{ */
+ const graph_ident_t *ident)
+{
+ size_t i;
+
+ if ((cfg == NULL) || (ident == NULL))
+ return (NULL);
+
+ for (i = 0; i < cfg->instances_num; i++)
+ if (inst_ident_matches (cfg->instances[i], ident))
+ return (cfg->instances[i]);
+
+ return (NULL);
+} /* }}} graph_instance_t *graph_inst_find_matching */
+
+int graph_inst_find_all_matching (graph_config_t *cfg, /* {{{ */
+ const graph_ident_t *ident,
+ graph_inst_callback_t callback, void *user_data)
+{
+ size_t i;
+
+ if ((cfg == NULL) || (ident == NULL) || (callback == NULL))
+ return (EINVAL);
+
+ for (i = 0; i < cfg->instances_num; i++)
+ {
+ int status;
+
+ if (!inst_matches_ident (cfg->instances[i], ident))
+ continue;
+
+ status = (*callback) (cfg, cfg->instances[i], user_data);
+ if (status != 0)
+ return (status);
+ }
+
+ return (0);
+} /* }}} int graph_inst_find_all_matching */
+
+/* Lightweight variant of the "graph_search_inst" which is used if the
+ * search_info_t doesn't select any field values explicitely. */
+static int graph_search_inst_noselector (graph_config_t *cfg, /* {{{ */
+ search_info_t *si, graph_inst_callback_t cb, void *user_data)
+{
+ char title[1024];
+ int status;
+ size_t i;
+
+ /* parameters have already been checked in "graph_search_inst" */
+
+ status = graph_get_title (cfg, title, sizeof (title));
+ if (status != 0)
+ {
+ fprintf (stderr, "graph_search_inst_noselector: "
+ "graph_get_title failed\n");
+ return (status);
+ }
+ strtolower (title);
+
+ for (i = 0; i < cfg->instances_num; i++)
+ {
+ if (search_graph_inst_matches (si, cfg, cfg->instances[i], title))
+ {
+ status = (*cb) (cfg, cfg->instances[i], user_data);
+ if (status != 0)
+ return (status);
+ }
+ } /* for (cfg->instances_num) */