X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_graph_helper.c;h=653586f3829e464511b741cfc458c1ad3318c18d;hb=ad994d046d175fec8f67cc3b7cddf3cb77d341be;hp=e7712216e5d15c78f30e7a81fc06a5f373413339;hpb=5b2064dee177834d41e3b7051faa7dc6cee85853;p=rrdtool.git diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index e771221..653586f 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -1,8 +1,8 @@ /**************************************************************************** - * RRDtool 1.2.x Copyright Tobias Oetiker, 1997 - 2005 + * RRDtool 1.2.0 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd_graph_helper.c commandline parser functions - * this code was probably writtenn by Alex van den Bogaerdt + * this code initially written by Alex van den Bogaerdt ****************************************************************************/ #include "rrd_graph.h" @@ -34,7 +34,7 @@ int rrd_parse_cdef (char *, unsigned int *, graph_desc_t *, image_desc_t *); int rrd_parse_find_gf(char *line, unsigned int *eaten, graph_desc_t *gdp) { - char funcname[11],c1=0,c2=0; + char funcname[11],c1=0; int i=0; sscanf(&line[*eaten], "DEBUG%n", &i); @@ -44,7 +44,7 @@ rrd_parse_find_gf(char *line, unsigned int *eaten, graph_desc_t *gdp) { i=0; dprintf("Scanning line '%s'\n",&line[*eaten]); } - sscanf(&line[*eaten], "%10[A-Z]%n%c%c", funcname, &i, &c1, &c2); + sscanf(&line[*eaten], "%10[A-Z]%n%c", funcname, &i, &c1); if (!i) { rrd_set_error("Could not make sense out of '%s'",line); return 1; @@ -54,12 +54,22 @@ rrd_parse_find_gf(char *line, unsigned int *eaten, graph_desc_t *gdp) { return 1; } if (gdp->gf == GF_LINE) { - if (c1 < '1' || c1 > '3' || c2 != ':') { - rrd_set_error("Malformed LINE command: %s",line); - return 1; + if (c1 == ':'){ + gdp->linewidth=1; + } else { + double width; + *eaten+=i; + if (sscanf(&line[*eaten],"%lf%n:",&width,&i)){ + if (width <= 0){ + rrd_set_error("LINE width is %lf. It must be >= 0 though",width); + return 1; + } + gdp->linewidth=width; + } else { + rrd_set_error("LINE width: %s",line); + return 1; + } } - gdp->linewidth=c1-'0'; - i++; } else { if (c1 != ':') { rrd_set_error("Malformed %s command: %s",funcname,line); @@ -97,9 +107,9 @@ rrd_parse_color(char *string, graph_desc_t *gdp) { sscanf(string, "#%02x%02x%02x%n%02x%n%*s%n", &r,&g,&b,&i1,&a,&i2,&i3); - if (i3) return 1; /* garbage after color */ - if (!i2) a=0xFF; - if (!i1) return 1; /* no color after '#' */ + if (i3) return 1; /* garbage after color */ + if (!i2) a=0xFF; /* default no transparency */ + if (!i1) return 1; /* no color after '#' */ gdp->col = r<<24|g<<16|b<<8|a; return 0; } @@ -163,7 +173,7 @@ rrd_parse_print(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc_t } if (rrd_parse_legend(line,eaten,gdp)) return 1; - /* for *PRINT the legend itself gets renderd later. We only + /* for *PRINT the legend itself gets rendered later. We only get the format at this juncture */ strcpy(gdp->format,gdp->legend); gdp->legend[0]='\0'; @@ -175,7 +185,7 @@ rrd_parse_shift(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc_t char *l = strdup(line + *eaten), *p; int rc = 1; - p = strchr(l, ','); + p = strchr(l, ':'); if (p == NULL) { rrd_set_error("Invalid SHIFT syntax"); goto out; @@ -370,6 +380,10 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc return 1; } } + /* have simpler code in the drawing section */ + if ( gdp->gf == GF_STACK ){ + gdp->stack=1; + } return 0; } @@ -589,6 +603,7 @@ rrd_graph_script(int argc, char *argv[], image_desc_t *im, int optno) { case GF_COMMENT: /* text */ if (rrd_parse_legend(argv[i],&eaten,gdp)) return; break; + case GF_STACK: /* vname-or-value[#color[:legend]] */ #ifdef WITH_PIECHART case GF_PART: /* value[#color[:legend]] */ #endif @@ -596,7 +611,6 @@ rrd_graph_script(int argc, char *argv[], image_desc_t *im, int optno) { case GF_HRULE: /* value#color[:legend] */ case GF_LINE: /* vname-or-value[#color[:legend]][:STACK] */ case GF_AREA: /* vname-or-value[#color[:legend]][:STACK] */ - case GF_STACK: /* vname-or-value[#color[:legend]] */ case GF_TICK: /* vname#color[:num[:legend]] */ if (rrd_parse_PVHLAST(argv[i],&eaten,gdp,im)) return; break;