summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 701f6f1)
raw | patch | inline | side by side (parent: 701f6f1)
author | Florian Forster <ff@octo.it> | |
Mon, 14 Jun 2010 15:09:01 +0000 (17:09 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 14 Jun 2010 15:09:01 +0000 (17:09 +0200) |
graph_ident.c | patch | blob | history | |
graph_ident.h | patch | blob | history | |
graph_list.c | patch | blob | history |
diff --git a/graph_ident.c b/graph_ident.c
index 9a52003c5a7dfd0816b1967cc1f5cf316e078c62..9252ebeae0e75a8e168a32c5df0bde96db840fcd 100644 (file)
--- a/graph_ident.c
+++ b/graph_ident.c
* Private functions
*/
static char *part_copy_with_selector (const char *selector, /* {{{ */
- const char *part, _Bool keep_all_selector)
+ const char *part, unsigned int flags)
{
if ((selector == NULL) || (part == NULL))
return (NULL);
- if (IS_ANY (part))
+ if ((flags & IDENT_FLAG_REPLACE_ANY) && IS_ANY (part))
return (NULL);
- if (!keep_all_selector && IS_ALL (part))
+ if ((flags & IDENT_FLAG_REPLACE_ALL) && IS_ALL (part))
return (NULL);
- /* ANY in the graph selection => concrete value in the instance. */
- if (IS_ANY (selector))
+ /* Replace the ANY and ALL flags if requested and if the selecter actually
+ * *is* that flag. */
+ if ((flags & IDENT_FLAG_REPLACE_ANY) && IS_ANY (selector))
return (strdup (part));
- if (IS_ALL (selector))
- {
- if (keep_all_selector)
- return (strdup (ALL_TOKEN));
- else
- return (strdup (part));
- }
+ if ((flags & IDENT_FLAG_REPLACE_ALL) && IS_ALL (selector))
+ return (strdup (part));
if (strcmp (selector, part) != 0)
return (NULL);
+ /* Otherwise (no replacement), return a copy of the selector. */
return (strdup (selector));
} /* }}} char *part_copy_with_selector */
return (ret);
} /* }}} graph_ident_t *ident_create */
-graph_ident_t *ident_clone (const graph_ident_t *ident)
+graph_ident_t *ident_clone (const graph_ident_t *ident) /* {{{ */
{
return (ident_create (ident->host,
ident->plugin, ident->plugin_instance,
} /* }}} graph_ident_t *ident_clone */
graph_ident_t *ident_copy_with_selector (const graph_ident_t *selector, /* {{{ */
- const graph_ident_t *ident, _Bool keep_all_selector)
+ const graph_ident_t *ident, unsigned int flags)
{
graph_ident_t *ret;
@@ -155,8 +152,7 @@ graph_ident_t *ident_copy_with_selector (const graph_ident_t *selector, /* {{{ *
ret->type_instance = NULL;
#define COPY_PART(p) do { \
- ret->p = part_copy_with_selector (selector->p, ident->p, \
- keep_all_selector); \
+ ret->p = part_copy_with_selector (selector->p, ident->p, flags); \
if (ret->p == NULL) \
{ \
free (ret->host); \
diff --git a/graph_ident.h b/graph_ident.h
index 09f3f0782aceb7f9354e2c93395e0e8c6b33cc3e..abc451db0edc95ee005f11fe93e7b2ef8b2dcbcd 100644 (file)
--- a/graph_ident.h
+++ b/graph_ident.h
const char *type, const char *type_instance);
graph_ident_t *ident_clone (const graph_ident_t *ident);
+#define IDENT_FLAG_REPLACE_ALL 0x01
+#define IDENT_FLAG_REPLACE_ANY 0x02
graph_ident_t *ident_copy_with_selector (const graph_ident_t *selector,
- const graph_ident_t *ident, _Bool keep_all_selector);
+ const graph_ident_t *ident, unsigned int flags);
void ident_destroy (graph_ident_t *ident);
diff --git a/graph_list.c b/graph_list.c
index 0a934776a7450ff5f72be38283334e03611e69af..8c5e7158208f57077e81886f2044d367e68dc090 100644 (file)
--- a/graph_list.c
+++ b/graph_list.c
memset (i, 0, sizeof (*i));
i->select = ident_copy_with_selector (cfg->select, file,
- /* keep_all_selector = */ 1);
+ IDENT_FLAG_REPLACE_ANY);
i->files = NULL;
i->files_num = 0;