X-Git-Url: https://git.octo.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils_search.c;h=ba5927be18e4dee45b4654898e75691f2350393e;hb=50d5299ef04975d005f86a0ec8a0556969129cd1;hp=6ed9c172c6e9a566fc0135c003be8a2191d96830;hpb=a573057438337ceb8821909f89dbbe87481a3dfd;p=collection4.git diff --git a/src/utils_search.c b/src/utils_search.c index 6ed9c17..ba5927b 100644 --- a/src/utils_search.c +++ b/src/utils_search.c @@ -28,6 +28,7 @@ #include #include "utils_search.h" +#include "graph_instance.h" #include "utils_array.h" #include @@ -233,4 +234,42 @@ void search_destroy (search_info_t *si) /* {{{ */ 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 : */