summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a573057)
raw | patch | inline | side by side (parent: a573057)
author | Florian Forster <ff@octo.it> | |
Mon, 12 Jul 2010 08:31:35 +0000 (10:31 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 12 Jul 2010 08:31:35 +0000 (10:31 +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 6ed9c172c6e9a566fc0135c003be8a2191d96830..ba5927be18e4dee45b4654898e75691f2350393e 100644 (file)
--- a/src/utils_search.c
+++ b/src/utils_search.c
#include <errno.h>
#include "utils_search.h"
+#include "graph_instance.h"
#include "utils_array.h"
#include <fcgiapp.h>
array_destroy (si->terms);
} /* }}} void search_destroy */
+_Bool search_graph_inst_matches (search_info_t *si, /* {{{ */
+ graph_config_t *cfg, graph_instance_t *inst)
+{
+ char **argv;
+ int argc;
+ int i;
+
+ if ((si == NULL) || (cfg == NULL) || (inst == NULL))
+ return (0);
+
+ if ((si->host != NULL)
+ && !inst_matches_field (inst, GIF_HOST, si->host))
+ return (0);
+ else if ((si->plugin != NULL)
+ && !inst_matches_field (inst, GIF_PLUGIN, si->plugin))
+ return (0);
+ else if ((si->plugin_instance != NULL)
+ && !inst_matches_field (inst, GIF_PLUGIN_INSTANCE, si->plugin_instance))
+ return (0);
+ else if ((si->type != NULL)
+ && !inst_matches_field (inst, GIF_TYPE, si->type))
+ return (0);
+ else if ((si->type_instance != NULL)
+ && !inst_matches_field (inst, GIF_TYPE_INSTANCE, si->type_instance))
+ 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 (!inst_matches_string (cfg, inst, argv[i]))
+ return (0);
+
+ return (1);
+} /* }}} _Bool search_graph_inst_matches */
+
/* vim: set sw=2 sts=2 et fdm=marker : */
diff --git a/src/utils_search.h b/src/utils_search.h
index a1fa643983337bc7e28f5d9d43659a56a8c35975..fc3f40ce340ade9396e058aa11e39d626fb8bec9 100644 (file)
--- a/src/utils_search.h
+++ b/src/utils_search.h
#ifndef UTILS_SEARCH_H
#define UTILS_SEARCH_H 1
+#include "graph_types.h"
+
struct search_info_s;
typedef struct search_info_s search_info_t;
search_info_t *search_parse (const char *search);
void search_destroy (search_info_t *si);
+_Bool search_graph_inst_matches (search_info_t *si,
+ graph_config_t *cfg, graph_instance_t *inst);
+
#endif /* UTILS_SEARCH_H */
/* vim: set sw=2 sts=2 et fdm=marker : */