- 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)
-{
- graph_instance_t *i;
-
- if ((cfg == NULL) || (file == NULL))
- return (NULL);
-
- for (i = cfg->instances; i != NULL; i = i->next)
- if (ident_matches (i->select, file))
- return (i);
-
- return (NULL);
-} /* }}} graph_instance_t *graph_find_instance */
-
-static int graph_add_file (graph_config_t *cfg, const graph_ident_t *file) /* {{{ */
-{
- graph_instance_t *inst;
-
- inst = graph_find_instance (cfg, file);
- if (inst == NULL)
- {
- inst = instance_create (cfg, file);
- if (inst == NULL)
- return (ENOMEM);
- }
-
- return (instance_add_file (inst, file));
-} /* }}} int graph_add_file */
-
-static int graph_append (graph_config_t **head, /* {{{ */
- graph_config_t *cfg)
-{
- graph_config_t *last;