-/* FIXME: These "print_*" functions are used for debugging. They should be
- * removed at some point. */
-static int print_files (const graph_instance_t *inst) /* {{{ */
-{
- size_t i;
-
- for (i = 0; i < inst->files_num; i++)
- {
- graph_ident_t *ident = inst->files[i];
- char *file;
-
- file = ident_to_file (ident);
- printf (" File \"%s\"\n", file);
- free (file);
- }
-
- return (0);
-} /* }}} int print_instances */
-
-static int print_instances (const graph_config_t *cfg) /* {{{ */
-{
- graph_instance_t *inst;
-
- for (inst = cfg->instances; inst != NULL; inst = inst->next)
- {
- char *str;
-
- str = ident_to_string (inst->select);
- printf (" Instance \"%s\"\n", str);
- free (str);
-
- print_files (inst);
- }
-
- return (0);
-} /* }}} int print_instances */
-
-static int print_graphs (void) /* {{{ */
-{
- graph_config_t *cfg;
-
- for (cfg = graph_config_head; cfg != NULL; cfg = cfg->next)
- {
- char *str;
-
- str = ident_to_string (cfg->select);
- printf ("Graph \"%s\"\n", str);
- free (str);
-
- print_instances (cfg);
- }
-
- return (0);
-} /* }}} int print_graphs */
-
-#if 0
-/* "Safe" version of strcmp(3): Either or both pointers may be NULL. */
-static int strcmp_s (const char *s1, const char *s2) /* {{{ */
-{
- if ((s1 == NULL) && (s2 == NULL))
- return (0);
- else if (s1 == NULL)
- return (1);
- else if (s2 == NULL)
- return (-1);
- assert ((s1 != NULL) && (s2 != NULL));
-
- return (strcmp (s1, s2));
-} /* }}} int strcmp_s */
-#endif
-
-static void instance_destroy (graph_instance_t *inst) /* {{{ */
-{
- graph_instance_t *next;
- size_t i;
-
- if (inst == NULL)
- return;
-
- next = inst->next;
-
- ident_destroy (inst->select);
-
- for (i = 0; i < inst->files_num; i++)
- ident_destroy (inst->files[i]);
- free (inst->files);
-
- free (inst);
-
- instance_destroy (next);
-} /* }}} void instance_destroy */
-
-/*
- * Copy part of an identifier. If the "template" value is ANY_TOKEN, "value" is
- * copied and returned. This function is used when creating graph_instance_t
- * from graph_config_t.
- */
-static graph_instance_t *instance_create (graph_config_t *cfg, /* {{{ */
- const graph_ident_t *file)
-{
- graph_instance_t *i;
-
- if ((cfg == NULL) || (file == NULL))
- return (NULL);
-
- i = malloc (sizeof (*i));
- if (i == NULL)
- return (NULL);
- memset (i, 0, sizeof (*i));
-
- i->select = ident_copy_with_selector (cfg->select, file,
- IDENT_FLAG_REPLACE_ANY);
- if (i->select == NULL)
- {
- DEBUG ("instance_create: ident_copy_with_selector returned NULL.\n");
- free (i);
- return (NULL);
- }
-
- i->files = NULL;
- i->files_num = 0;
-
- i->next = NULL;
-
- if (cfg->instances == NULL)
- cfg->instances = i;
- else
- {
- graph_instance_t *last;
-
- last = cfg->instances;
- while (last->next != NULL)
- last = last->next;
-
- last->next = i;
- }
-
- return (i);
-} /* }}} graph_instance_t *instance_create */
-
-static int instance_add_file (graph_instance_t *inst, /* {{{ */
- const graph_ident_t *file)
-{
- graph_ident_t **tmp;
-
- tmp = realloc (inst->files, sizeof (*inst->files) * (inst->files_num + 1));
- if (tmp == NULL)
- return (ENOMEM);
- inst->files = tmp;
-
- inst->files[inst->files_num] = ident_clone (file);
- if (inst->files[inst->files_num] == NULL)
- return (ENOMEM);
-
- inst->files_num++;
-
- return (0);
-} /* }}} int instance_add_file */
-
-static graph_instance_t *graph_find_instance (graph_config_t *cfg, /* {{{ */
- const graph_ident_t *file)