summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6777c7f)
raw | patch | inline | side by side (parent: 6777c7f)
author | Florian Forster <ff@octo.it> | |
Wed, 28 Jul 2010 15:15:57 +0000 (17:15 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Wed, 28 Jul 2010 15:15:57 +0000 (17:15 +0200) |
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 aa157e6df6307d925bd8a173535de22cec9f67dc..1a1be7d798f28ccab564d0d6c1ec30921e20c3a1 100644 (file)
--- a/src/utils_search.c
+++ b/src/utils_search.c
#include <errno.h>
#include "utils_search.h"
+#include "graph_ident.h"
#include "graph_instance.h"
#include "utils_array.h"
(si->type_instance == NULL) ? ANY_TOKEN : si->type_instance));
} /* }}} graph_ident_t *search_to_ident */
+search_info_t *search_from_ident (const graph_ident_t *ident) /* {{{ */
+{
+ search_info_t *si;
+
+ if (ident == NULL)
+ return (NULL);
+
+ si = malloc (sizeof (*si));
+ if (si == NULL)
+ return (NULL);
+ memset (si, 0, sizeof (*si));
+ si->terms = NULL;
+
+#define COPY_FIELD(f) do { \
+ const char *tmp = ident_get_##f (ident); \
+ if (tmp == NULL) \
+ si->f = NULL; \
+ else \
+ si->f = strdup (tmp); \
+} while (0)
+
+ COPY_FIELD(host);
+ COPY_FIELD(plugin);
+ COPY_FIELD(plugin_instance);
+ COPY_FIELD(type);
+ COPY_FIELD(type_instance);
+
+#undef COPY_FIELD
+
+ return (si);
+} /* }}} search_info_t *search_from_ident */
+
_Bool search_graph_title_matches (search_info_t *si, /* {{{ */
const char *title)
{
diff --git a/src/utils_search.h b/src/utils_search.h
index 746edccd976c007f304d8970ad1387da9e83f469..62ab6cee9534fa6620992e42b267c14155361e31 100644 (file)
--- a/src/utils_search.h
+++ b/src/utils_search.h
_Bool search_has_selector (search_info_t *si);
graph_ident_t *search_to_ident (search_info_t *si);
+search_info_t *search_from_ident (const graph_ident_t *ident);
_Bool search_graph_title_matches (search_info_t *si, const char *title);