summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b31c5fd)
raw | patch | inline | side by side (parent: b31c5fd)
author | Florian Forster <ff@octo.it> | |
Mon, 12 Jul 2010 09:44:12 +0000 (11:44 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 12 Jul 2010 09:44:12 +0000 (11:44 +0200) |
The "title" argument has been added to the "search_graph_inst_matches" function, too.
src/utils_search.c | patch | blob | history | |
src/utils_search.h | patch | blob | history |
diff --git a/src/utils_search.c b/src/utils_search.c
index ba5927be18e4dee45b4654898e75691f2350393e..e2a89f30a305896d2aec86620a11e01ac7ab8867 100644 (file)
--- a/src/utils_search.c
+++ b/src/utils_search.c
array_destroy (si->terms);
} /* }}} void search_destroy */
+graph_ident_t *search_to_ident (search_info_t *si) /* {{{ */
+{
+ if (si == NULL)
+ return (NULL);
+
+ return (ident_create ((si->host == NULL) ? ANY_TOKEN : si->host,
+ (si->plugin == NULL) ? ANY_TOKEN : si->plugin,
+ (si->plugin_instance == NULL) ? ANY_TOKEN : si->plugin_instance,
+ (si->type == NULL) ? ANY_TOKEN : si->type,
+ (si->type_instance == NULL) ? ANY_TOKEN : si->type_instance));
+} /* }}} graph_ident_t *search_to_ident */
+
+_Bool search_graph_title_matches (search_info_t *si, /* {{{ */
+ const char *title)
+{
+ char **argv;
+ int argc;
+ int i;
+
+ if ((si == NULL) || (title == NULL))
+ return (0);
+
+ if (si->terms == NULL)
+ return (1);
+
+ argc = array_argc (si->terms);
+ argv = array_argv (si->terms);
+ for (i = 0; i < argc; i++)
+ if (strstr (title, argv[i]) == NULL)
+ return (0);
+
+ return (1);
+} /* }}} _Bool search_graph_title_matches */
+
_Bool search_graph_inst_matches (search_info_t *si, /* {{{ */
- graph_config_t *cfg, graph_instance_t *inst)
+ graph_config_t *cfg, graph_instance_t *inst,
+ const char *title)
{
char **argv;
int argc;
argc = array_argc (si->terms);
argv = array_argv (si->terms);
for (i = 0; i < argc; i++)
- if (!inst_matches_string (cfg, inst, argv[i]))
- return (0);
+ {
+ if (inst_matches_string (cfg, inst, argv[i]))
+ continue;
+
+ if ((title != NULL) && (strstr (title, argv[i]) != NULL))
+ continue;
+
+ return (0);
+ }
return (1);
} /* }}} _Bool search_graph_inst_matches */
diff --git a/src/utils_search.h b/src/utils_search.h
index fc3f40ce340ade9396e058aa11e39d626fb8bec9..5e3e2b8e7ea711e658ac0d8d506e9c8a646f880b 100644 (file)
--- a/src/utils_search.h
+++ b/src/utils_search.h
search_info_t *search_parse (const char *search);
void search_destroy (search_info_t *si);
+graph_ident_t *search_to_ident (search_info_t *si);
+
+_Bool search_graph_title_matches (search_info_t *si, const char *title);
+
_Bool search_graph_inst_matches (search_info_t *si,
- graph_config_t *cfg, graph_instance_t *inst);
+ graph_config_t *cfg, graph_instance_t *inst,
+ const char *title);
#endif /* UTILS_SEARCH_H */
/* vim: set sw=2 sts=2 et fdm=marker : */