From 6dddafca4941220ae3d5f2bb85ab913570c50b03 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 14 Jul 2010 10:18:26 +0200 Subject: [PATCH] src/utils_search.[ch]: Implement "search_has_selector". --- src/utils_search.c | 13 +++++++++++++ src/utils_search.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/utils_search.c b/src/utils_search.c index e2a89f3..aa157e6 100644 --- a/src/utils_search.c +++ b/src/utils_search.c @@ -234,6 +234,19 @@ void search_destroy (search_info_t *si) /* {{{ */ array_destroy (si->terms); } /* }}} void search_destroy */ +_Bool search_has_selector (search_info_t *si) /* {{{ */ +{ + if (si == NULL) + return (0); + + if ((si->host != NULL) + || (si->plugin != NULL) || (si->plugin_instance != NULL) + || (si->type != NULL) || (si->type_instance != NULL)) + return (1); + + return (0); +} /* }}} _Bool search_has_selector */ + graph_ident_t *search_to_ident (search_info_t *si) /* {{{ */ { if (si == NULL) diff --git a/src/utils_search.h b/src/utils_search.h index 5e3e2b8..746edcc 100644 --- a/src/utils_search.h +++ b/src/utils_search.h @@ -32,6 +32,11 @@ typedef struct search_info_s search_info_t; search_info_t *search_parse (const char *search); void search_destroy (search_info_t *si); +/* Returns true if at least one of the ident fields is defined (not a + * wildcard), false otherwise. If no field has been specified, searching is a + * lot easier. */ +_Bool search_has_selector (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); -- 2.30.2