X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgraph_instance.c;h=89fdcfbc6a5b8a249e2b0ed977bcbd6c36471b02;hb=1c73ff974cb2a94f83ae1869f8267def13742bd8;hp=5431589cfa9f4ed4f1c3074c8734f0065f8cc7be;hpb=95cad1f9e58e9f1a5480e62fc2cdd2c3de33a863;p=collection4.git diff --git a/src/graph_instance.c b/src/graph_instance.c index 5431589..89fdcfb 100644 --- a/src/graph_instance.c +++ b/src/graph_instance.c @@ -1,3 +1,26 @@ +/** + * collection4 - graph_instance.c + * Copyright (C) 2010 Florian octo Forster + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301 USA + * + * Authors: + * Florian octo Forster + **/ + #include #include #include @@ -26,7 +49,7 @@ struct graph_instance_s /* {{{ */ struct def_callback_data_s { graph_instance_t *inst; - str_array_t *args; + rrd_args_t *args; }; typedef struct def_callback_data_s def_callback_data_t; @@ -124,7 +147,7 @@ static int gl_instance_get_rrdargs_cb (graph_def_t *def, void *user_data) /* {{{ { def_callback_data_t *data = user_data; graph_instance_t *inst = data->inst; - str_array_t *args = data->args; + rrd_args_t *args = data->args; size_t i; @@ -311,7 +334,7 @@ int inst_get_all_selected (graph_config_t *cfg, /* {{{ */ int inst_get_rrdargs (graph_config_t *cfg, /* {{{ */ graph_instance_t *inst, - str_array_t *args) + rrd_args_t *args) { def_callback_data_t data = { inst, args }; graph_def_t *defs; @@ -410,6 +433,12 @@ int inst_get_params (graph_config_t *cfg, graph_instance_t *inst, /* {{{ */ return (0); } /* }}} int inst_get_params */ +int inst_compare (const graph_instance_t *i0, /* {{{ */ + const graph_instance_t *i1) +{ + return (ident_compare (i0->select, i1->select)); +} /* }}} int inst_compare */ + int inst_compare_ident (graph_instance_t *inst, /* {{{ */ const graph_ident_t *ident) { @@ -422,8 +451,10 @@ int inst_compare_ident (graph_instance_t *inst, /* {{{ */ _Bool inst_ident_matches (graph_instance_t *inst, /* {{{ */ const graph_ident_t *ident) { +#if C4_DEBUG if ((inst == NULL) || (ident == NULL)) return (0); +#endif return (ident_matches (inst->select, ident)); } /* }}} _Bool inst_ident_matches */ @@ -507,6 +538,7 @@ int inst_describe (graph_config_t *cfg, graph_instance_t *inst, /* {{{ */ char *buffer, size_t buffer_size) { graph_ident_t *cfg_select; + int status; if ((cfg == NULL) || (inst == NULL) || (buffer == NULL) || (buffer_size < 2)) @@ -519,31 +551,12 @@ int inst_describe (graph_config_t *cfg, graph_instance_t *inst, /* {{{ */ return (-1); } - buffer[0] = 0; - -#define CHECK_FIELD(field) do { \ - if (IS_ANY (ident_get_##field (cfg_select))) \ - { \ - if (buffer[0] != 0) \ - strlcat (buffer, "/", buffer_size); \ - strlcat (buffer, ident_get_##field (inst->select), buffer_size); \ - } \ -} while (0) - - CHECK_FIELD (host); - CHECK_FIELD (plugin); - CHECK_FIELD (plugin_instance); - CHECK_FIELD (type); - CHECK_FIELD (type_instance); - -#undef CHECK_FIELD - - if (buffer[0] == 0) - strlcat (buffer, "default", buffer_size); + status = ident_describe (inst->select, cfg_select, + buffer, buffer_size); ident_destroy (cfg_select); - return (0); + return (status); } /* }}} int inst_describe */ time_t inst_get_mtime (graph_instance_t *inst) /* {{{ */