X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=graph_def.c;h=181788a9524dcced958980ae70c4a9088f6918c8;hb=06d714ac1654f84e0330717951515f7ae8793077;hp=80f6a0c78379c17a9e9f653c471494ae9ffc7c18;hpb=701f6f1bacb09b94be70490ac90cad5759687ff5;p=collection4.git diff --git a/graph_def.c b/graph_def.c index 80f6a0c..181788a 100644 --- a/graph_def.c +++ b/graph_def.c @@ -12,6 +12,8 @@ struct graph_def_s { graph_ident_t *select; + uint32_t color; + graph_def_t *next; }; @@ -38,6 +40,7 @@ graph_def_t *def_create (graph_config_t *cfg, graph_ident_t *ident) /* {{{ */ return (NULL); } memset (ret, 0, sizeof (*ret)); + ret->color = get_random_color (); ret->next = NULL; ret->select = ident_copy_with_selector (selector, ident, @@ -69,6 +72,22 @@ void def_destroy (graph_def_t *def) /* {{{ */ def_destroy (next); } /* }}} void def_destroy */ +int def_append (graph_def_t *head, graph_def_t *def) /* {{{ */ +{ + graph_def_t *ptr; + + if ((head == NULL) || (def == NULL)) + return (EINVAL); + + ptr = head; + while (ptr->next != NULL) + ptr = ptr->next; + + ptr->next = def; + + return (0); +} /* }}} int def_append */ + graph_def_t *def_search (graph_def_t *head, graph_ident_t *ident) /* {{{ */ { graph_def_t *ptr; @@ -138,7 +157,7 @@ int def_get_rrdargs (graph_def_t *def, graph_ident_t *ident, /* {{{ */ /* Graph part */ array_append_format (args, "LINE1:def_%04i_avg#%06"PRIx32":%s", - index, get_random_color (), dses[i]); + index, def->color, dses[i]); array_append_format (args, "GPRINT:vdef_%04i_min:%%lg min,", index); array_append_format (args, "GPRINT:vdef_%04i_avg:%%lg avg,", index); array_append_format (args, "GPRINT:vdef_%04i_max:%%lg max,", index);