diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c
index 1a022473a1c6ddd818481fb323119ecccb965848..25943a272cc385a63677e9432842fe1bf0f03f88 100644 (file)
--- a/src/rrd_graph_helper.c
+++ b/src/rrd_graph_helper.c
/****************************************************************************
/****************************************************************************
- * RRDtool 1.3rc9 Copyright by Tobi Oetiker, 1997-2008
+ * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010
****************************************************************************
* rrd_graph_helper.c commandline parser functions
* this code initially written by Alex van den Bogaerdt
****************************************************************************
* rrd_graph_helper.c commandline parser functions
* this code initially written by Alex van den Bogaerdt
}
}
-/* Parsing of PART, VRULE, HRULE, LINE, AREA, STACK and TICK
+/* Parsing of VRULE, HRULE, LINE, AREA, STACK and TICK
** is done in one function.
**
** is done in one function.
**
-** Stacking PART, VRULE, HRULE or TICK is not allowed.
+** Stacking VRULE, HRULE or TICK is not allowed.
**
** If a number (which is valid to enter) is more than a
** certain amount of characters, it is caught as an error.
**
** If a number (which is valid to enter) is more than a
** certain amount of characters, it is caught as an error.
graph_desc_t *const gdp,
image_desc_t *const im)
{
graph_desc_t *const gdp,
image_desc_t *const im)
{
- int i, j, k;
+ int i, j, k, j2;
int colorfound = 0;
char tmpstr[MAX_VNAME_LEN + 10]; /* vname#RRGGBBAA\0 */
static int spacecnt = 0;
int colorfound = 0;
char tmpstr[MAX_VNAME_LEN + 10]; /* vname#RRGGBBAA\0 */
static int spacecnt = 0;
float one_space = gfx_get_text_width(im, 0,
im->
text_prop[TEXT_PROP_LEGEND].
float one_space = gfx_get_text_width(im, 0,
im->
text_prop[TEXT_PROP_LEGEND].
- font,
- im->
- text_prop[TEXT_PROP_LEGEND].
- size,
+ font_desc,
im->tabwidth, " ") / 4.0;
float target_space = gfx_get_text_width(im, 0,
im->
text_prop
im->tabwidth, " ") / 4.0;
float target_space = gfx_get_text_width(im, 0,
im->
text_prop
- [TEXT_PROP_LEGEND].font,
- im->
- text_prop
- [TEXT_PROP_LEGEND].size,
+ [TEXT_PROP_LEGEND].font_desc,
im->tabwidth, "oo");
spacecnt = target_space / one_space;
im->tabwidth, "oo");
spacecnt = target_space / one_space;
rrd_set_error("Cannot parse line '%s'", line);
return 1;
}
rrd_set_error("Cannot parse line '%s'", line);
return 1;
}
-
- j = i;
+
+ j = i;
while (j > 0 && tmpstr[j] != '#')
j--;
while (j > 0 && tmpstr[j] != '#')
j--;
+ //see if there is a second color
+ j2 = j-1;
+ while (j2 > 0 && tmpstr[j2] != '#')
+ j2--;
+ if (j && j2) { //yes, swap j and j2, so that j is first color, j2 is second
+ int tmp = j;
+ j = j2;
+ j2 = tmp;
+ tmpstr[j2] = '\0';
+ } else {
+ j2 = 0;
+ }
if (j) {
tmpstr[j] = '\0';
if (j) {
tmpstr[j] = '\0';
/* We now have:
* tmpstr[0] containing vname
* tmpstr[j] if j!=0 then containing color
/* We now have:
* tmpstr[0] containing vname
* tmpstr[j] if j!=0 then containing color
- * i size of vname + color
+ * tmpstr[j2] if j2!=0 then containing second color
+ * i size of vname
* j if j!=0 then size of vname
* j if j!=0 then size of vname
+ * j2 if j2!=0 then size of vname + first color
*/
/* Number or vname ?
*/
/* Number or vname ?
dprintf("- parsed color %0.0f,%0.0f,%0.0f,%0.0f\n", gdp->col.red,
gdp->col.green, gdp->col.blue, gdp->col.alpha);
colorfound = 1;
dprintf("- parsed color %0.0f,%0.0f,%0.0f,%0.0f\n", gdp->col.red,
gdp->col.green, gdp->col.blue, gdp->col.alpha);
colorfound = 1;
+ if (j2) { //second color?
+ j2++;
+ dprintf("- examining second color '%s'\n", &tmpstr[j2]);
+ //TODO: maybe rrd_parse_color should take a pointer to gdp->col instead of gdp
+ struct gfx_color_t firstcol = gdp->col;
+ if (rrd_parse_color(&tmpstr[j2], gdp)) {
+ rrd_set_error("Could not parse color in '%s'", &tmpstr[j2]);
+ return 1;
+ }
+ dprintf("- parsed color %0.0f,%0.0f,%0.0f,%0.0f\n", gdp->col.red,
+ gdp->col.green, gdp->col.blue, gdp->col.alpha);
+ gdp->col2 = gdp->col;
+ gdp->col = firstcol;
+ //we now have a mandatory grid height
+ (*eaten) += i;
+ if (line[*eaten] != '\0') {
+ (*eaten)++;
+ }
+ dprintf("- examining gradient height\n");
+ i = scan_for_col(&line[*eaten], MAX_VNAME_LEN + 9, tmpstr);
+ sscanf(tmpstr, "%lf%n", &gdp->gradheight, &j);
+ if (i != j) {
+ rrd_set_error("Could not parse gradient height in '%s'", tmpstr);
+ return 1;
+ }
+ dprintf("- parsed gradientheight %0.0f\n", gdp->gradheight);
+ }
} else {
dprintf("- no color present in '%s'\n", tmpstr);
}
} else {
dprintf("- no color present in '%s'\n", tmpstr);
}
}
(*eaten)++; /* after colon */
}
(*eaten)++; /* after colon */
- /* PART, HRULE, VRULE and TICK cannot be stacked. */
+ /* HRULE, VRULE and TICK cannot be stacked. */
if ((gdp->gf != GF_HRULE)
&& (gdp->gf != GF_VRULE)
&& (gdp->gf != GF_TICK)) {
if ((gdp->gf != GF_HRULE)
&& (gdp->gf != GF_VRULE)
&& (gdp->gf != GF_TICK)) {
rrd_set_error("Cannot parse vname from '%s'", line);
return 1;
}
rrd_set_error("Cannot parse vname from '%s'", line);
return 1;
}
+ if (line[*eaten+i] == '\0') {
+ rrd_set_error("String ends after the = sign on '%s'", line);
+ return 1;
+ }
dprintf("- found candidate '%s'\n", tmpstr);
if ((gdp->vidx = find_var(im, tmpstr)) >= 0) {
dprintf("- found candidate '%s'\n", tmpstr);
if ((gdp->vidx = find_var(im, tmpstr)) >= 0) {
return 1;
}
dprintf("- done parsing: '%s'\n", &line[*eaten]);
return 1;
}
dprintf("- done parsing: '%s'\n", &line[*eaten]);
+ } else if (!strcmp("daemon", command)) {
+ i = scan_for_col(&line[*eaten],
+ sizeof (gdp->daemon), gdp->daemon);
+ (*eaten) += i;
+ dprintf("- using daemon '%s'\n", gdp->daemon);
} else {
rrd_set_error("Parse error in '%s'", line);
return 1;
} else {
rrd_set_error("Parse error in '%s'", line);
return 1;
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_HRULE: /* value#color[:legend] */
case GF_LINE: /* vname-or-value[#color[:legend]][:STACK] */
case GF_AREA: /* vname-or-value[#color[:legend]][:STACK] */
+ case GF_GRAD: /* vname-or-value[#color[:legend][#color[:gradientheight]]][:STACK] */
case GF_TICK: /* vname#color[:num[:legend]] */
if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
return;
case GF_TICK: /* vname#color[:num[:legend]] */
if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
return;
case GF_STACK: /* vname-or-value[#color[:legend]] */
if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
return;
case GF_STACK: /* vname-or-value[#color[:legend]] */
if (rrd_parse_PVHLAST(argv[i], &eaten, gdp, im))
return;
- if (last_gf == GF_LINE || last_gf == GF_AREA) {
+ if (last_gf == GF_LINE || last_gf == GF_AREA || last_gf == GF_GRAD) {
gdp->gf = last_gf;
gdp->linewidth = last_linewidth;
} else {
gdp->gf = last_gf;
gdp->linewidth = last_linewidth;
} else {