X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgraph_list.c;h=d2416f4d4772c9fd07fd48b830a7bbb95b5cbed5;hb=e30594797655c82d92ee8c4718dfdd82e9e3d377;hp=cf0ca4af8694e4766a627e1318536bb8ed00ff82;hpb=50d5299ef04975d005f86a0ec8a0556969129cd1;p=collection4.git diff --git a/src/graph_list.c b/src/graph_list.c index cf0ca4a..d2416f4 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,60 @@ 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); + + if (search_has_selector (si)) + { + ident = search_to_ident (si); + if (ident == NULL) + { + fprintf (stderr, "gl_search: search_to_ident failed\n"); + return (-1); + } + } + else + { + ident = NULL; + } + + for (i = 0; i < gl_active_num; i++) + { + int status; + + if ((ident != NULL) && !graph_ident_intersect (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 ((ident != NULL) && !graph_ident_intersect (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) {