X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=graph_list.c;h=3c8d375d1573eaa88ab7bc836ac06f0fd1ed20a9;hb=e850a3c5fb03dcb0e8698e61db2fd01a845bc6cf;hp=6e11894c544959138625bdec14e7d8930de33529;hpb=f61054f1c4bdda9cdb8fed14add70bcfe4132349;p=collection4.git diff --git a/graph_list.c b/graph_list.c index 6e11894..3c8d375 100644 --- a/graph_list.c +++ b/graph_list.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "graph_list.h" #include "graph_ident.h" @@ -23,22 +22,6 @@ */ #define UPDATE_INTERVAL 10 -#define ANY_TOKEN "/any/" -#define ALL_TOKEN "/all/" - -/* - * Data types - */ -struct gl_ident_stage_s /* {{{ */ -{ - char *host; - char *plugin; - char *plugin_instance; - char *type; - char *type_instance; -}; /* }}} */ -typedef struct gl_ident_stage_s gl_ident_stage_t; - /* * Global variables */ @@ -53,22 +36,6 @@ static time_t gl_last_update = 0; /* * Private functions */ -#if 0 -/* "Safe" version of strcmp(3): Either or both pointers may be NULL. */ -static int strcmp_s (const char *s1, const char *s2) /* {{{ */ -{ - if ((s1 == NULL) && (s2 == NULL)) - return (0); - else if (s1 == NULL) - return (1); - else if (s2 == NULL) - return (-1); - assert ((s1 != NULL) && (s2 != NULL)); - - return (strcmp (s1, s2)); -} /* }}} int strcmp_s */ -#endif - int gl_add_graph_internal (graph_config_t *cfg, /* {{{ */ graph_config_t ***gl_array, size_t *gl_array_num) { @@ -161,7 +128,7 @@ int gl_add_graph (graph_config_t *cfg) /* {{{ */ return (gl_add_graph_internal (cfg, &gl_staging, &gl_staging_num)); } /* }}} int gl_add_graph */ -int graph_config_submit (void) /* {{{ */ +int gl_config_submit (void) /* {{{ */ { graph_config_t **old; size_t old_num; @@ -186,7 +153,7 @@ int graph_config_submit (void) /* {{{ */ return (0); } /* }}} int graph_config_submit */ -int gl_graph_get_all (gl_cfg_callback callback, /* {{{ */ +int gl_graph_get_all (graph_callback_t callback, /* {{{ */ void *user_data) { size_t i; @@ -208,7 +175,7 @@ int gl_graph_get_all (gl_cfg_callback callback, /* {{{ */ return (0); } /* }}} int gl_graph_get_all */ -graph_config_t *graph_get_selected (void) /* {{{ */ +graph_config_t *gl_graph_get_selected (void) /* {{{ */ { const char *host = get_part_from_param ("graph_host", "host"); const char *plugin = get_part_from_param ("graph_plugin", "plugin"); @@ -238,13 +205,13 @@ graph_config_t *graph_get_selected (void) /* {{{ */ ident_destroy (ident); return (NULL); -} /* }}} graph_config_t *graph_get_selected */ +} /* }}} graph_config_t *gl_graph_get_selected */ /* gl_instance_get_all, gl_graph_instance_get_all {{{ */ struct gl_inst_callback_data /* {{{ */ { graph_config_t *cfg; - gl_inst_callback callback; + graph_inst_callback_t callback; void *user_data; }; /* }}} struct gl_inst_callback_data */ @@ -257,7 +224,7 @@ static int gl_inst_callback_handler (graph_instance_t *inst, /* {{{ */ } /* }}} int gl_inst_callback_handler */ int gl_graph_instance_get_all (graph_config_t *cfg, /* {{{ */ - gl_inst_callback callback, void *user_data) + graph_inst_callback_t callback, void *user_data) { struct gl_inst_callback_data data = { @@ -269,11 +236,11 @@ int gl_graph_instance_get_all (graph_config_t *cfg, /* {{{ */ if ((cfg == NULL) || (callback == NULL)) return (EINVAL); - return (inst_foreach (gl_graph_get_instances (cfg), + return (inst_foreach (graph_get_instances (cfg), gl_inst_callback_handler, &data)); } /* }}} int gl_graph_instance_get_all */ -int gl_instance_get_all (gl_inst_callback callback, /* {{{ */ +int gl_instance_get_all (graph_inst_callback_t callback, /* {{{ */ void *user_data) { size_t i; @@ -293,10 +260,28 @@ int gl_instance_get_all (gl_inst_callback callback, /* {{{ */ } /* }}} int gl_instance_get_all */ /* }}} gl_instance_get_all, gl_graph_instance_get_all */ +int gl_search (const char *term, graph_inst_callback_t callback, /* {{{ */ + void *user_data) +{ + size_t i; + + for (i = 0; i < gl_active_num; i++) + { + int status; + + status = graph_search (gl_active[i], term, + /* callback = */ callback, + /* user data = */ user_data); + if (status != 0) + return (status); + } + + return (0); +} /* }}} int gl_search */ + int gl_update (void) /* {{{ */ { time_t now; - gl_ident_stage_t gl; int status; /* @@ -310,13 +295,6 @@ int gl_update (void) /* {{{ */ graph_read_config (); - memset (&gl, 0, sizeof (gl)); - gl.host = NULL; - gl.plugin = NULL; - gl.plugin_instance = NULL; - gl.type = NULL; - gl.type_instance = NULL; - gl_clear_instances (); status = fs_scan (/* callback = */ gl_register_file, /* user data = */ NULL);