From: Florian Forster Date: Mon, 12 Jul 2010 09:44:47 +0000 (+0200) Subject: src/graph_list.[ch]: Implement "gl_search". X-Git-Tag: v4.0.0~101 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=6997bcaa3a362fd4c48a0909e0b88a4e1db5bf6a;p=collection4.git src/graph_list.[ch]: Implement "gl_search". --- diff --git a/src/graph_list.c b/src/graph_list.c index cf0ca4a..a33697f 100644 --- a/src/graph_list.c +++ b/src/graph_list.c @@ -37,6 +37,7 @@ #include "graph_def.h" #include "graph_ident.h" #include "utils_cgi.h" +#include "utils_search.h" #include #include @@ -381,6 +382,53 @@ int gl_instance_get_all (graph_inst_callback_t callback, /* {{{ */ } /* }}} int gl_instance_get_all */ /* }}} gl_instance_get_all, gl_graph_instance_get_all */ +int gl_search (search_info_t *si, /* {{{ */ + graph_inst_callback_t callback, void *user_data) +{ + size_t i; + graph_ident_t *ident; + + if ((si == NULL) || (callback == NULL)) + return (EINVAL); + + ident = search_to_ident (si); + if (ident == NULL) + { + fprintf (stderr, "gl_search: search_to_ident failed\n"); + return (-1); + } + + for (i = 0; i < gl_active_num; i++) + { + int status; + + if (!graph_matches_ident (gl_active[i], ident)) + continue; + + status = graph_search_inst (gl_active[i], si, + /* callback = */ callback, + /* user data = */ user_data); + if (status != 0) + return (status); + } + + for (i = 0; i < gl_dynamic_num; i++) + { + int status; + + if (!graph_matches_ident (gl_dynamic[i], ident)) + continue; + + status = graph_search_inst (gl_dynamic[i], si, + /* callback = */ callback, + /* user data = */ user_data); + if (status != 0) + return (status); + } + + return (0); +} /* }}} int gl_search */ + int gl_search_string (const char *term, graph_inst_callback_t callback, /* {{{ */ void *user_data) { diff --git a/src/graph_list.h b/src/graph_list.h index b238a9e..b25fb21 100644 --- a/src/graph_list.h +++ b/src/graph_list.h @@ -26,6 +26,7 @@ #include "graph_types.h" #include "graph_ident.h" +#include "utils_search.h" /* * Functions @@ -43,6 +44,9 @@ int gl_graph_instance_get_all (graph_config_t *cfg, graph_inst_callback_t callba int gl_instance_get_all (graph_inst_callback_t callback, void *user_data); +int gl_search (search_info_t *si, graph_inst_callback_t callback, + void *user_data); + int gl_search_string (const char *search, graph_inst_callback_t callback, void *user_data);